Skip to content

Commit

Permalink
Merge pull request #1860 from MVrachev/serialization-bytes-array
Browse files Browse the repository at this point in the history
Metadata test full serialization cycle
  • Loading branch information
Jussi Kukkonen authored Mar 7, 2022
2 parents 29e4e63 + be2c8f0 commit e7037cf
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 @@ -80,8 +80,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 e7037cf

Please sign in to comment.