Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.loader.tests.test_init::test_check_snapshot_failures
Failed

TEST RESULT

Run At
Nov 4 2021, 3:53 PM
Details
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7f0c0c097b38> def test_check_snapshot_failures(swh_storage): """Failure scenarios: 0. snapshot parameter is not a snapshot 1. snapshot id is correct but branches mismatched 2. snapshot id is not correct, it's not found in the storage 3. snapshot reference an alias which does not exist 4. snapshot is found in storage, targeted revision does not exist 5. snapshot is found in storage, targeted revision exists but the directory the revision targets does not exist 6. snapshot is found in storage, target revision exists, targeted directory by the revision exist. Content targeted by the directory does not exist. 7. snapshot is found in storage, targeted release does not exist """ snap_id_hex = "2498dbf535f882bc7f9a18fb16c9ad27fda7bab7" snapshot = Snapshot( id=hash_to_bytes(snap_id_hex), branches={ b"master": SnapshotBranch( target=hash_to_bytes(hash_hex), target_type=TargetType.REVISION, ), }, ) s = swh_storage.snapshot_add([snapshot]) assert s == { "snapshot:add": 1, } unexpected_snapshot = Snapshot( branches={ b"tip": SnapshotBranch( # wrong branch target=hash_to_bytes(hash_hex), target_type=TargetType.RELEASE ) }, ) # 0. not a Snapshot object, raise! with pytest.raises(AssertionError, match="variable 'snapshot' must be a snapshot"): > check_snapshot(ORIGIN_VISIT, swh_storage) .tox/py3/lib/python3.7/site-packages/swh/loader/tests/test_init.py:404: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ expected_snapshot = OriginVisit(origin='some-url', date=datetime.datetime(2021, 11, 4, 14, 53, 25, 10846, tzinfo=datetime.timezone.utc), type='archive', visit=1) storage = <swh.storage.postgresql.storage.Storage object at 0x7f0c0c097b38> allowed_empty = [] def check_snapshot( expected_snapshot: Snapshot, storage: StorageInterface, allowed_empty: Iterable[Tuple[TargetType, bytes]] = [], ) -> Snapshot: """Check that: - snapshot exists in the storage and match - each object reference up to the revision/release targets exists Args: expected_snapshot: full snapshot to check for existence and consistency storage: storage to lookup information into allowed_empty: Iterable of branch we allow to be empty (some edge case loaders allows this case to happen, nixguix for example allows the branch evaluation" to target the nixpkgs git commit reference, which may not yet be resolvable at loading time) Returns: the snapshot stored in the storage for further test assertion if any is needed. """ if not isinstance(expected_snapshot, Snapshot): raise AssertionError( > f"argument 'expected_snapshot' must be a snapshot: {expected_snapshot!r}" ) E AssertionError: argument 'expected_snapshot' must be a snapshot: OriginVisit(origin='some-url', date=datetime.datetime(2021, 11, 4, 14, 53, 25, 10846, tzinfo=datetime.timezone.utc), type='archive', visit=1) .tox/py3/lib/python3.7/site-packages/swh/loader/tests/__init__.py:141: AssertionError During handling of the above exception, another exception occurred: swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7f0c0c097b38> def test_check_snapshot_failures(swh_storage): """Failure scenarios: 0. snapshot parameter is not a snapshot 1. snapshot id is correct but branches mismatched 2. snapshot id is not correct, it's not found in the storage 3. snapshot reference an alias which does not exist 4. snapshot is found in storage, targeted revision does not exist 5. snapshot is found in storage, targeted revision exists but the directory the revision targets does not exist 6. snapshot is found in storage, target revision exists, targeted directory by the revision exist. Content targeted by the directory does not exist. 7. snapshot is found in storage, targeted release does not exist """ snap_id_hex = "2498dbf535f882bc7f9a18fb16c9ad27fda7bab7" snapshot = Snapshot( id=hash_to_bytes(snap_id_hex), branches={ b"master": SnapshotBranch( target=hash_to_bytes(hash_hex), target_type=TargetType.REVISION, ), }, ) s = swh_storage.snapshot_add([snapshot]) assert s == { "snapshot:add": 1, } unexpected_snapshot = Snapshot( branches={ b"tip": SnapshotBranch( # wrong branch target=hash_to_bytes(hash_hex), target_type=TargetType.RELEASE ) }, ) # 0. not a Snapshot object, raise! with pytest.raises(AssertionError, match="variable 'snapshot' must be a snapshot"): > check_snapshot(ORIGIN_VISIT, swh_storage) E AssertionError: Regex pattern "variable 'snapshot' must be a snapshot" does not match "argument 'expected_snapshot' must be a snapshot: OriginVisit(origin='some-url', date=datetime.datetime(2021, 11, 4, 14, 53, 25, 10846, tzinfo=datetime.timezone.utc), type='archive', visit=1)". .tox/py3/lib/python3.7/site-packages/swh/loader/tests/test_init.py:404: AssertionError