Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/tests/test_cookers.py
Show First 20 Lines • Show All 966 Lines • ▼ Show 20 Lines | def test_revision_filtered_objects(self, git_loader, cook_extract_revision): | ||||
with cook_extract_revision(loader.storage, swhid) as (ert, p): | with cook_extract_revision(loader.storage, swhid) as (ert, p): | ||||
self.check_revision_filtered_objects(ert, p, swhid) | self.check_revision_filtered_objects(ert, p, swhid) | ||||
def test_revision_null_fields(self, git_loader, cook_extract_revision): | def test_revision_null_fields(self, git_loader, cook_extract_revision): | ||||
(loader, swhid) = self.load_repo_null_fields(git_loader) | (loader, swhid) = self.load_repo_null_fields(git_loader) | ||||
with cook_extract_revision(loader.storage, swhid, fsck=False) as (ert, p): | with cook_extract_revision(loader.storage, swhid, fsck=False) as (ert, p): | ||||
self.check_revision_null_fields(ert, p, swhid) | self.check_revision_null_fields(ert, p, swhid) | ||||
def test_revision_submodule(self, swh_storage, cook_extract_revision): | @pytest.mark.parametrize("ingest_target_revision", [False, True]) | ||||
target_rev = "0e8a3ad980ec179856012b7eecf4327e99cd44cd" | def test_revision_submodule( | ||||
self, swh_storage, cook_extract_revision, ingest_target_revision | |||||
): | |||||
date = TimestampWithTimezone.from_datetime( | date = TimestampWithTimezone.from_datetime( | ||||
datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) | datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) | ||||
) | ) | ||||
target_rev = Revision( | |||||
message=b"target_rev", | |||||
author=Person.from_fullname(b"me <test@example.org>"), | |||||
date=date, | |||||
committer=Person.from_fullname(b"me <test@example.org>"), | |||||
committer_date=date, | |||||
parents=(), | |||||
type=RevisionType.GIT, | |||||
directory=bytes.fromhex("3333333333333333333333333333333333333333"), | |||||
metadata={}, | |||||
synthetic=True, | |||||
) | |||||
if ingest_target_revision: | |||||
swh_storage.revision_add([target_rev]) | |||||
dir = Directory( | dir = Directory( | ||||
entries=( | entries=( | ||||
DirectoryEntry( | DirectoryEntry( | ||||
name=b"submodule", | name=b"submodule", type="rev", target=target_rev.id, perms=0o160000, | ||||
type="rev", | |||||
target=hashutil.hash_to_bytes(target_rev), | |||||
perms=0o160000, | |||||
), | ), | ||||
), | ), | ||||
) | ) | ||||
swh_storage.directory_add([dir]) | swh_storage.directory_add([dir]) | ||||
rev = Revision( | rev = Revision( | ||||
message=b"msg", | message=b"msg", | ||||
author=Person.from_fullname(b"me <test@example.org>"), | author=Person.from_fullname(b"me <test@example.org>"), | ||||
date=date, | date=date, | ||||
committer=Person.from_fullname(b"me <test@example.org>"), | committer=Person.from_fullname(b"me <test@example.org>"), | ||||
committer_date=date, | committer_date=date, | ||||
parents=(), | parents=(), | ||||
type=RevisionType.GIT, | type=RevisionType.GIT, | ||||
directory=dir.id, | directory=dir.id, | ||||
metadata={}, | metadata={}, | ||||
synthetic=True, | synthetic=True, | ||||
) | ) | ||||
swh_storage.revision_add([rev]) | swh_storage.revision_add([rev]) | ||||
with cook_extract_revision(swh_storage, rev.swhid()) as (ert, p): | with cook_extract_revision(swh_storage, rev.swhid()) as (ert, p): | ||||
ert.checkout(b"HEAD") | ert.checkout(b"HEAD") | ||||
pattern = b"160000 submodule\x00%s" % hashutil.hash_to_bytes(target_rev) | pattern = b"160000 submodule\x00%s" % target_rev.id | ||||
tree = ert.repo[b"HEAD"].tree | tree = ert.repo[b"HEAD"].tree | ||||
assert pattern in ert.repo[tree].as_raw_string() | assert pattern in ert.repo[tree].as_raw_string() | ||||
anlambert: Is is possible to check if the `target_rev` revision got cooked based on the… | |||||
vlorentzAuthorUnsubmitted Done Inline ActionsThe test always runs git-fsck; and the only point of this change is to make git-fsck happy. So I think that's good enough. vlorentz: The test always runs git-fsck; and the only point of this change is to make git-fsck happy. So… | |||||
anlambertUnsubmitted Not Done Inline ActionsOk, looks good then. anlambert: Ok, looks good then. | |||||
class TestSnapshotCooker(RepoFixtures): | class TestSnapshotCooker(RepoFixtures): | ||||
def test_snapshot_simple(self, git_loader, cook_extract_snapshot): | def test_snapshot_simple(self, git_loader, cook_extract_snapshot): | ||||
(loader, main_rev_id) = self.load_repo_simple(git_loader) | (loader, main_rev_id) = self.load_repo_simple(git_loader) | ||||
snp_id = loader.loaded_snapshot_id | snp_id = loader.loaded_snapshot_id | ||||
swhid = CoreSWHID(object_type=ObjectType.SNAPSHOT, object_id=snp_id) | swhid = CoreSWHID(object_type=ObjectType.SNAPSHOT, object_id=snp_id) | ||||
with cook_extract_snapshot(loader.storage, swhid) as (ert, p): | with cook_extract_snapshot(loader.storage, swhid) as (ert, p): | ||||
self.check_revision_simple(ert, p, main_rev_id) | self.check_revision_simple(ert, p, main_rev_id) | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Is is possible to check if the target_rev revision got cooked based on the ingest_target_revision value ?