diff --git a/tests/test_api.py b/tests/test_api.py index 2a2ebc997f..6f7d615588 100755 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -585,6 +585,13 @@ def test_metadata_targets(self): targets.signed.targets[filename].to_dict(), fileinfo.to_dict() ) + # Test from_dict/to_dict Targets with empty targets. + targets_dict = copy.deepcopy(targets.to_dict()) + targets_dict["signed"]["targets"] = {} + tmp_dict = copy.deepcopy(targets_dict["signed"]) + targets_obj = Targets.from_dict(tmp_dict) + self.assertEqual(targets_dict["signed"], targets_obj.to_dict()) + # Test from_dict/to_dict Targets without delegations targets_dict = targets.to_dict() del targets_dict["signed"]["delegations"]