@@ -318,13 +318,12 @@ def test_add_metric_and_ddata_msg(timestamp: float, metrics: list[dict]):
318
318
sparkplug_message = SpBMessageGenerator ()
319
319
payload = sparkplug_message .get_device_data_payload (timestamp = timestamp )
320
320
alias = 0
321
+ # creating the payload from the dict object provided as parameter
321
322
for metric in metrics :
322
323
name : str = metric ["name" ]
323
324
datatype : int = metric ["datatype" ]
324
325
value = metric .get ("value" , None )
325
- metric_timestamp = metric .get ("timestamp" , None )
326
- if metric_timestamp is None :
327
- metric_timestamp = timestamp
326
+ metric_timestamp = metric .get ("timestamp" , timestamp )
328
327
sparkplug_message .add_metric (
329
328
payload_or_template = payload , name = name , alias = alias , datatype = datatype , value = value , timestamp = metric_timestamp
330
329
)
@@ -594,9 +593,7 @@ def test_add_historical_metric_and_ddata_msg(metrics: list[dict]):
594
593
name : str = metric ["name" ]
595
594
datatype : int = metric ["datatype" ]
596
595
value = metric .get ("value" , None )
597
- metric_timestamp = metric .get ("timestamp" , None )
598
- if metric_timestamp is None :
599
- metric_timestamp = timestamp
596
+ metric_timestamp = metric .get ("timestamp" , timestamp )
600
597
sparkplug_message .add_historical_metric (
601
598
payload = payload , name = name , datatype = datatype , value = value , timestamp = metric_timestamp
602
599
)
0 commit comments