Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion k2eg/dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ def __consumer_handler(self):
handler_data = {}
# Add 'iter_index' and 'timestamp' if present and not already set
handler_data["iteration"] = snapshot.interation
handler_data["timestamp"] = snapshot.timestamp
# timetamp of the header
handler_data["header_timestamp"] = snapshot.timestamp
# timstamp of the tail
handler_data["tail_timestamp"] = decoded_message.get('timestamp', snapshot.timestamp)
# add key and value from snapshot.results
# to the handler data
for pv_name, values in snapshot.results.items():
Expand Down
13 changes: 8 additions & 5 deletions tests/test_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,15 @@ def snapshot_handler(id, snapshot_data:Dict[str, Any]):
assert len(received_snapshot) > 0, "snapshot should not be None"
#print a json description for the dictionary
print(received_snapshot[0])
assert received_snapshot[0]['timestamp'] > 0, "timestamp should be valid"
assert received_snapshot[0]['header_timestamp'] > 0, "header_timestamp should be valid"
assert received_snapshot[0]['tail_timestamp'] > 0, "tail_timestamp should be valid"
assert received_snapshot[0]['iteration'] > 0, "interation should be valid"
assert 'variable:a' in received_snapshot[0] and isinstance(received_snapshot[0]['variable:a'], list), "variable:a need be contained into the snapshot"
assert 'variable:b' in received_snapshot[0] and isinstance(received_snapshot[1]['variable:a'], list), "variable:b need be contained into the snapshot"
except Exception as e:
assert False, f"An error occured: {e}"
finally:
k.snapshot_stop(snapshot_name)
time.sleep(1)


def test_recurring_snapshot_check_for_empty_pv():
Expand Down Expand Up @@ -413,7 +413,8 @@ def snapshot_handler(id, snapshot_data:Snapshot):
k.snapshot_stop(snapshot_name)
time.sleep(1)
assert len(received_snapshot) == 2 , "snapshot should only one"
assert received_snapshot[0]['timestamp'] > 0, "timestamp should be valid"
assert received_snapshot[0]['header_timestamp'] > 0, "header_timestamp should be valid"
assert received_snapshot[0]['tail_timestamp'] > 0, "tail_timestamp should be valid"
assert received_snapshot[0]['iteration'] > 0, "interation should be valid"
assert 'variable:a' in received_snapshot[0] and isinstance(received_snapshot[0]['variable:a'], list), "variable:a need be contained into the snapshot"
assert 'variable:b' in received_snapshot[0] and isinstance(received_snapshot[1]['variable:a'], list), "variable:b need be contained into the snapshot"
Expand Down Expand Up @@ -460,7 +461,8 @@ def snapshot_handler(id, snapshot_data:Dict[str, Any]):
assert len(received_snapshot) > 0, "snapshot should not be None"
#print a json description for the dictionary
print(received_snapshot[0])
assert received_snapshot[0]['timestamp'] > 0, "timestamp should be valid"
assert received_snapshot[0]['header_timestamp'] > 0, "header_timestamp should be valid"
assert received_snapshot[0]['tail_timestamp'] > 0, "tail_timestamp should be valid"
assert received_snapshot[0]['iteration'] > 0, "interation should be valid"
assert 'channel:ramp:ramp' in received_snapshot[0] and isinstance(received_snapshot[0]['channel:ramp:ramp'], list), "variable:a need be contained into the snapshot"
assert 'channel:ramp:rampa' in received_snapshot[0] and isinstance(received_snapshot[0]['channel:ramp:rampa'], list), "variable:b need be contained into the snapshot"
Expand Down Expand Up @@ -509,7 +511,8 @@ def snapshot_handler(id, snapshot_data:Dict[str, Any]):
assert len(received_snapshot) > 0, "snapshot should not be None"
#print a json description for the dictionary
print(received_snapshot[0])
assert received_snapshot[0]['timestamp'] > 0, "timestamp should be valid"
assert received_snapshot[0]['header_timestamp'] > 0, "header_timestamp should be valid"
assert received_snapshot[0]['tail_timestamp'] > 0, "tail_timestamp should be valid"
assert received_snapshot[0]['iteration'] > 0, "interation should be valid"
assert 'channel:ramp:ramp' in received_snapshot[0] and isinstance(received_snapshot[0]['channel:ramp:ramp'], list), "variable:a need be contained into the snapshot"
# channel:ramp:ramp need to have four values
Expand Down