Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.package.npm.tests.test_npm::test_npm_loader_first_visit
Failed

TEST RESULT

Run At
Mar 2 2021, 10:24 AM
Details
swh_storage = <swh.storage.retry.RetryingProxyStorage object at 0x7f77d21adb70> requests_mock_datadir = <requests_mock.mocker.Mocker object at 0x7f77d21d8cf8> org_api_info = b'{\n "_id": "org",\n "_rev": "4-22484cc537f12d3023241211ee34e39d",\n "name": "org",\n "description": "A parser an...rser"\n ],\n "bugs": {\n "url": "http://github.com/mooz/org-s/issues"\n },\n "readmeFilename": "README.md"\n}\n' def test_npm_loader_first_visit(swh_storage, requests_mock_datadir, org_api_info): package = "org" url = package_url(package) loader = NpmLoader(swh_storage, url) actual_load_status = loader.load() expected_snapshot_id = hash_to_bytes("d0587e1195aed5a8800411a008f2f2d627f18e2d") assert actual_load_status == { "status": "eventful", "snapshot_id": expected_snapshot_id.hex(), } assert_last_visit_matches( swh_storage, url, status="full", type="npm", snapshot=expected_snapshot_id ) stats = get_stats(swh_storage) assert { "content": len(_expected_new_contents_first_visit), "directory": len(_expected_new_directories_first_visit), "origin": 1, "origin_visit": 1, "release": 0, "revision": len(_expected_new_revisions_first_visit), "skipped_content": 0, "snapshot": 1, } == stats contents = swh_storage.content_get(_expected_new_contents_first_visit) count = sum(0 if content is None else 1 for content in contents) assert count == len(_expected_new_contents_first_visit) assert ( list(swh_storage.directory_missing(_expected_new_directories_first_visit)) == [] ) assert list(swh_storage.revision_missing(_expected_new_revisions_first_visit)) == [] versions = [ ("0.0.2", "d8a1c7474d2956ac598a19f0f27d52f7015f117e"), ("0.0.3", "5f9eb78af37ffd12949f235e86fac04898f9f72a"), ("0.0.4", "ba019b192bdb94bd0b5bd68b3a5f92b5acc2239a"), ] expected_snapshot = Snapshot( id=expected_snapshot_id, branches={ b"HEAD": SnapshotBranch( target=b"releases/0.0.4", target_type=TargetType.ALIAS ), **{ b"releases/" + version_name.encode(): SnapshotBranch( target=hash_to_bytes(version_id), target_type=TargetType.REVISION, ) for (version_name, version_id) in versions }, }, ) check_snapshot(expected_snapshot, swh_storage) metadata_authority = MetadataAuthority( type=MetadataAuthorityType.FORGE, url="https://npmjs.com/", ) for (version_name, revision_id) in versions: revision = swh_storage.revision_get([hash_to_bytes(revision_id)])[0] directory_id = revision.directory directory_swhid = ExtendedSWHID( object_type=ExtendedObjectType.DIRECTORY, object_id=directory_id, ) revision_swhid = CoreSWHID( > object_type=ObjectType.REVISION, object_id=revision_id, ) .tox/py3/lib/python3.7/site-packages/swh/loader/package/npm/tests/test_npm.py:416: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ <attrs generated init swh.model.identifiers.CoreSWHID>:11: in __init__ __attr_validator_object_id(self, __attr_object_id, self.object_id) .tox/py3/lib/python3.7/site-packages/attr/_make.py:2723: in __call__ v(inst, attr, value) .tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:105: in _validator _validate_elements(attribute, field, attribute.type) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ attribute = Attribute(name='object_id', default=NOTHING, validator=_AndValidator(_validators=(<function type_validator.<locals>._v...t=True, metadata=mappingproxy({}), type=<class 'bytes'>, converter=None, kw_only=True, inherited=True, on_setattr=None) value = 'd8a1c7474d2956ac598a19f0f27d52f7015f117e' expected_type = <class 'bytes'> def _validate_elements(attribute, value, expected_type): if expected_type is None: return base_type = _get_base_type(expected_type) if base_type == typing.Any: return if isinstance(base_type, (str, ForwardRef)): # These base_types happen when you have string annotations and cannot # be used in isinstance. raise _StringAnnotationError() elif base_type == Literal or base_type == type(Literal): # type: ignore _handle_literal(attribute, value, expected_type) elif base_type == typing.Union: # type: ignore _handle_union(attribute, value, expected_type) elif not isinstance(value, base_type): > raise AttributeTypeError(value, attribute) E attrs_strict._error.AttributeTypeError: object_id must be <class 'bytes'> (got d8a1c7474d2956ac598a19f0f27d52f7015f117e that is a <class 'str'>) .tox/py3/lib/python3.7/site-packages/attrs_strict/_type_validation.py:131: AttributeTypeError