Skip to content

Commit

Permalink
Metadata test full serialization cycle
Browse files Browse the repository at this point in the history
Replace the usage of Metadata.to_dict inside
test_valid_metadata_serialization and instead use Metadata.to_bytes()
in order to test that the full serialization cycle is working as
expected:
Metadata.from_bytes -> Metadata.to_bytes

Signed-off-by: Martin Vrachev <[email protected]>
  • Loading branch information
MVrachev committed Feb 12, 2022
1 parent a347d03 commit be2c8f0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_metadata_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ def test_invalid_metadata_serialization(self, test_data: bytes) -> None:
@utils.run_sub_tests_with_dataset(valid_metadata)
def test_valid_metadata_serialization(self, test_case_data: bytes) -> None:
md = Metadata.from_bytes(test_case_data)
input_dict = json.loads(test_case_data)
self.assertDictEqual(input_dict, md.to_dict())

# Convert to a JSON and sort the keys the way we do in JSONSerializer.
separators = (",", ":")
test_json = json.loads(test_case_data)
test_bytes = json.dumps(
test_json, separators=separators, sort_keys=True
).encode("utf-8")

self.assertEqual(test_bytes, md.to_bytes())

invalid_signatures: utils.DataSet = {
"missing keyid attribute in a signature": '{ "sig": "abc" }',
Expand Down

0 comments on commit be2c8f0

Please sign in to comment.