Page MenuHomeSoftware Heritage
Paste P971

(An Untitled Masterwork)
ActivePublic

Authored by douardda on Mar 8 2021, 2:13 PM.
______________ test_swh_model_todict_fromdict[metadata_authority-objects3] _______________
object_type = 'metadata_authority'
objects = [MetadataAuthority(type=<MetadataAuthorityType.FORGE: 'forge'>, url='http://example.org/', metadata=ImmutableDict({}))]
@pytest.mark.parametrize("object_type, objects", TEST_OBJECTS.items())
def test_swh_model_todict_fromdict(object_type, objects):
"""checks model objects in swh_model_data are in correct shape"""
assert objects
for obj in objects:
# Check the composition of from_dict and to_dict is the identity
obj_as_dict = obj.to_dict()
assert obj == type(obj).from_dict(obj_as_dict)
> assert obj_as_dict == type(obj).from_dict(obj_as_dict).to_dict()
E AssertionError: assert {'metadata': {},\n 'type': <MetadataAuthorityType.FORGE: 'forge'>,\n 'url': 'http://example.org/'} == {'metadata': {}, 'type': 'forge', 'url': 'http://example.org/'}
E Common items:
E {'metadata': {}, 'url': 'http://example.org/'}
E Differing items:
E {'type': <MetadataAuthorityType.FORGE: 'forge'>} != {'type': 'forge'}
E Full diff:
E {
E 'metadata': {},
E - 'type': 'forge',
E + 'type': <MetadataAuthorityType.FORGE: 'forge'>,
E 'url': 'http://example.org/',
E }
swh/model/tests/test_model.py:90: AssertionError
____________ test_swh_model_todict_fromdict[raw_extrinsic_metadata-objects8] _____________
object_type = 'raw_extrinsic_metadata'
objects = [RawExtrinsicMetadata(target=ExtendedSWHID(namespace='swh', scheme_version=1, object_id=b'\x88\xc3\xa1\xfc\xec\xd7\x8d...se=None, revision=None, path=None, directory=None, id=b'\x02\x06\xf7%DI\x00P-\xe4\xf47\xc3\xca\x1c\x80\n\xda\xc4\xec')]
@pytest.mark.parametrize("object_type, objects", TEST_OBJECTS.items())
def test_swh_model_todict_fromdict(object_type, objects):
"""checks model objects in swh_model_data are in correct shape"""
assert objects
for obj in objects:
# Check the composition of from_dict and to_dict is the identity
obj_as_dict = obj.to_dict()
assert obj == type(obj).from_dict(obj_as_dict)
> assert obj_as_dict == type(obj).from_dict(obj_as_dict).to_dict()
E assert {'authority': {'type': <MetadataAuthorityType.FORGE: 'forge'>,\n 'url': 'http://example.org/'},\n 'discovery_date': datetime.datetime(2020, 7, 30, 17, 8, 20, tzinfo=datetime.timezone.utc),\n 'fetcher': {'name': 'test-fetcher', 'version': '1.0.0'},\n 'format': 'json',\n 'id': b'aT\xc9\xb3\xcf\xefq\x03\xf2\xa1z\xa7\xd3p\xb3.\xbd\xb7\xbb\x00',\n 'metadata': b'{"foo": "bar"}',\n 'target': 'swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca'} == {'authority': {'type': 'forge', 'url': 'http://example.org/'},\n 'discovery_date': datetime.datetime(2020, 7, 30, 17, 8, 20, tzinfo=datetime.timezone.utc),\n 'fetcher': {'name': 'test-fetcher', 'version': '1.0.0'},\n 'format': 'json',\n 'id': b'aT\xc9\xb3\xcf\xefq\x03\xf2\xa1z\xa7\xd3p\xb3.\xbd\xb7\xbb\x00',\n 'metadata': b'{"foo": "bar"}',\n 'target': 'swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca'}
E Common items:
E {'discovery_date': datetime.datetime(2020, 7, 30, 17, 8, 20, tzinfo=datetime.timezone.utc),
E 'fetcher': {'name': 'test-fetcher', 'version': '1.0.0'},
E 'format': 'json',
E 'id': b'aT\xc9\xb3\xcf\xefq\x03\xf2\xa1z\xa7\xd3p\xb3.\xbd\xb7\xbb\x00',
E 'metadata': b'{"foo": "bar"}',
E 'target': 'swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca'}
E Differing items:
E {'authority': {'type': <MetadataAuthorityType.FORGE: 'forge'>, 'url': 'http://example.org/'}} != {'authority': {'type': 'forge', 'url': 'http://example.org/'}}
E Full diff:
E {
E - 'authority': {'type': 'forge',
E + 'authority': {'type': <MetadataAuthorityType.FORGE: 'forge'>,
E 'url': 'http://example.org/'},
E 'discovery_date': datetime.datetime(2020, 7, 30, 17, 8, 20, tzinfo=datetime.timezone.utc),
E 'fetcher': {'name': 'test-fetcher',
E 'version': '1.0.0'},
E 'format': 'json',
E 'id': b'aT\xc9\xb3\xcf\xefq\x03\xf2\xa1z\xa7\xd3p\xb3.\xbd\xb7\xbb\x00',
E 'metadata': b'{"foo": "bar"}',
E 'target': 'swh:1:ori:88c3a1fcecd78d2daef7e33634cc493db9fb84ca',
E }
swh/model/tests/test_model.py:90: AssertionError

Event Timeline

Added test being:

@pytest.mark.parametrize("object_type, objects", TEST_OBJECTS.items())
def test_swh_model_todict_fromdict(object_type, objects):
    """checks model objects in swh_model_data are in correct shape"""
    assert objects
    for obj in objects:
        # Check the composition of from_dict and to_dict is the identity
        obj_as_dict = obj.to_dict()
        assert obj == type(obj).from_dict(obj_as_dict)
        assert obj_as_dict == type(obj).from_dict(obj_as_dict).to_dict()