OpenC3/cosmos

View on GitHub
openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/procedures/metadata.py

Summary

Maintainability
A
0 mins
Test Coverage
# Example of using metadata. Note each call to metadata_set creates a new entry.
# metadata_update without a start time will update the latest metadata entry.
print(metadata_get())
print(metadata_set({"setkey": 1}))
check_expression(f"{len(metadata_all())} >= 1")
check_expression(f"{metadata_get()['metadata']} == {{'setkey':1}}")
print(metadata_get()["metadata"])
print(metadata_update({"setkey": 2, "updatekey": 3}))
check_expression(f"{metadata_get()['metadata']['setkey']} == 2")
check_expression(f"{metadata_get()['metadata']['updatekey']} == 3")
print(metadata_update({"setkey": 4}))  # Ensure updatekey stays
check_expression(f"{metadata_get()['metadata']['setkey']} == 4")
check_expression(f"{metadata_get()['metadata']['updatekey']} == 3")
check_expression(f"{len(metadata_all())} >= 1")
metadata_input()  # Creates a new entry
metadata_set({"input": 5})  # Simulate metadat_input for now
check_expression(f"{len(metadata_all())} >= 2")
wait(2)  # Allow time to advance or it's an error
metadata_set({"new": 5})  # Another new entry
check_expression(f"{len(metadata_all())} >= 3")
print(metadata_all())