self = <swh.loader.git.tests.test_loader.TestDumbGitLoaderWithoutPack object at 0x7fbbf4d0b438>
def test_load_filter_branches(self):
filtered_branches = {b"refs/pull/42/merge"}
unfiltered_branches = {b"refs/pull/42/head"}
# Add branches to the repository on disk; some should be filtered by
# the loader, some should not.
for branch_name in filtered_branches | unfiltered_branches:
self.repo[branch_name] = self.repo[b"refs/heads/master"]
# Generate the expected snapshot from SNAPSHOT1 (which is the original
# state of the git repo)...
branches = dict(SNAPSHOT1.branches)
# ... and the unfiltered_branches, which are all pointing to the same
# commit as "refs/heads/master".
for branch_name in unfiltered_branches:
branches[branch_name] = branches[b"refs/heads/master"]
expected_snapshot = Snapshot(branches=branches)
# Load the modified repository
res = self.loader.load()
assert res == {"status": "eventful"}
> check_snapshot(expected_snapshot, self.loader.storage)
.tox/py3/lib/python3.7/site-packages/swh/loader/git/tests/test_from_disk.py:362:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
snapshot = Snapshot(branches=ImmutableDict({b'HEAD': SnapshotBranch(target=b'refs/heads/master', target_type=<TargetType.ALIAS: '...t\xa6I", target_type=<TargetType.REVISION: 'revision'>)}), id=b'\xcap\x01IT\xef\xdc\x0f\xdel\xa1PV)\xd2\x91\x81Ka\xe5')
storage = <swh.storage.proxies.filter.FilteringProxyStorage object at 0x7fbbf4cd2908>
allowed_empty = []
def check_snapshot(
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:
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(snapshot, Snapshot):
raise AssertionError(f"variable 'snapshot' must be a snapshot: {snapshot!r}")
expected_snapshot = snapshot_get_all_branches(storage, snapshot.id)
if expected_snapshot is None:
> raise AssertionError(f"Snapshot {snapshot.id.hex()} is not found")
E AssertionError: Snapshot ca70014954efdc0fde6ca1505629d291814b61e5 is not found
.tox/py3/lib/python3.7/site-packages/swh/loader/tests/__init__.py:144: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 1 2021, 4:22 PM