Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_archive.py
Show First 20 Lines • Show All 1,063 Lines • ▼ Show 20 Lines | |||||
@given(snapshot()) | @given(snapshot()) | ||||
def test_lookup_snapshot_alias(snapshot): | def test_lookup_snapshot_alias(snapshot): | ||||
resolved_alias = archive.lookup_snapshot_alias(snapshot, "HEAD") | resolved_alias = archive.lookup_snapshot_alias(snapshot, "HEAD") | ||||
assert resolved_alias is not None | assert resolved_alias is not None | ||||
assert resolved_alias["target_type"] == "revision" | assert resolved_alias["target_type"] == "revision" | ||||
assert resolved_alias["target"] is not None | assert resolved_alias["target"] is not None | ||||
@given(revision()) | @given(revision()) | ||||
def test_lookup_snapshot_missing(revision): | |||||
with pytest.raises(NotFoundExc): | |||||
archive.lookup_snapshot(revision) | |||||
anlambert: `revision` parameter is already in hexadecimal representation, you can remove the call to… | |||||
@given(revision()) | |||||
def test_lookup_snapshot_empty_branch_list(archive_data, revision): | |||||
rev_id = hash_to_bytes(revision) | |||||
snapshot = Snapshot( | |||||
branches={ | |||||
b"refs/heads/master": SnapshotBranch( | |||||
target=rev_id, target_type=TargetType.REVISION, | |||||
), | |||||
}, | |||||
) | |||||
archive_data.snapshot_add([snapshot]) | |||||
Not Done Inline ActionsCan you be more specific about the inconsistency in the comment ? anlambert: Can you be more specific about the inconsistency in the comment ? | |||||
# FIXME; This test will change once the inconsistency in storage is fixed | |||||
# postgres backend returns None in case of a missing branch whereas the | |||||
# in-memory implementation (used in tests) returns a data structure; | |||||
# hence the inconsistency | |||||
branches = archive.lookup_snapshot( | |||||
hash_to_hex(snapshot.id), branch_name_include_substring="non-existing", | |||||
)["branches"] | |||||
assert not branches | |||||
@given(revision()) | |||||
def test_lookup_snapshot_branch_names_filtering(archive_data, revision): | def test_lookup_snapshot_branch_names_filtering(archive_data, revision): | ||||
rev_id = hash_to_bytes(revision) | rev_id = hash_to_bytes(revision) | ||||
snapshot = Snapshot( | snapshot = Snapshot( | ||||
branches={ | branches={ | ||||
b"refs/heads/master": SnapshotBranch( | b"refs/heads/master": SnapshotBranch( | ||||
target=rev_id, target_type=TargetType.REVISION, | target=rev_id, target_type=TargetType.REVISION, | ||||
), | ), | ||||
b"refs/heads/incoming": SnapshotBranch( | b"refs/heads/incoming": SnapshotBranch( | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
revision parameter is already in hexadecimal representation, you can remove the call to hash_to_*
Could you also add a test checking that searching for a non existing branch name returns without raising an exception ?