Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/tests/test_revision_content_layer.py
Show First 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | for synth_rev in synthetic_revision_content_result(syntheticfile): | ||||
), synth_rev["msg"] | ), synth_rev["msg"] | ||||
# check for R-C (direct) entries | # check for R-C (direct) entries | ||||
# these are added directly in the content_early_in_rev table | # these are added directly in the content_early_in_rev table | ||||
rows["content_in_revision"] |= set( | rows["content_in_revision"] |= set( | ||||
(x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["R_C"] | (x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["R_C"] | ||||
) | ) | ||||
assert rows["content_in_revision"] == { | assert rows["content_in_revision"] == { | ||||
(rel.src, rel.dst, rel.path) | (src, rel.dst, rel.path) | ||||
for rel in provenance.storage.relation_get_all( | for src, rels in provenance.storage.relation_get_all( | ||||
RelationType.CNT_EARLY_IN_REV | RelationType.CNT_EARLY_IN_REV | ||||
) | ).items() | ||||
for rel in rels | |||||
}, synth_rev["msg"] | }, synth_rev["msg"] | ||||
# check timestamps | # check timestamps | ||||
for rc in synth_rev["R_C"]: | for rc in synth_rev["R_C"]: | ||||
assert ( | assert ( | ||||
rev_ts + rc["rel_ts"] | rev_ts + rc["rel_ts"] | ||||
== provenance.storage.content_get([rc["dst"]])[rc["dst"]].timestamp() | == provenance.storage.content_get([rc["dst"]])[rc["dst"]].timestamp() | ||||
), synth_rev["msg"] | ), synth_rev["msg"] | ||||
# check directories | # check directories | ||||
# each directory stored in the provenance index is an entry | # each directory stored in the provenance index is an entry | ||||
# in the "directory" table... | # in the "directory" table... | ||||
rows["directory"] |= set(x["dst"] for x in synth_rev["R_D"]) | rows["directory"] |= set(x["dst"] for x in synth_rev["R_D"]) | ||||
assert rows["directory"] == provenance.storage.entity_get_all( | assert rows["directory"] == provenance.storage.entity_get_all( | ||||
EntityType.DIRECTORY | EntityType.DIRECTORY | ||||
), synth_rev["msg"] | ), synth_rev["msg"] | ||||
# ... + a number of rows in the "directory_in_rev" table... | # ... + a number of rows in the "directory_in_rev" table... | ||||
# check for R-D entries | # check for R-D entries | ||||
rows["directory_in_revision"] |= set( | rows["directory_in_revision"] |= set( | ||||
(x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["R_D"] | (x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["R_D"] | ||||
) | ) | ||||
assert rows["directory_in_revision"] == { | assert rows["directory_in_revision"] == { | ||||
(rel.src, rel.dst, rel.path) | (src, rel.dst, rel.path) | ||||
for rel in provenance.storage.relation_get_all(RelationType.DIR_IN_REV) | for src, rels in provenance.storage.relation_get_all( | ||||
RelationType.DIR_IN_REV | |||||
).items() | |||||
for rel in rels | |||||
}, synth_rev["msg"] | }, synth_rev["msg"] | ||||
# check timestamps | # check timestamps | ||||
for rd in synth_rev["R_D"]: | for rd in synth_rev["R_D"]: | ||||
assert ( | assert ( | ||||
rev_ts + rd["rel_ts"] | rev_ts + rd["rel_ts"] | ||||
== provenance.storage.directory_get([rd["dst"]])[rd["dst"]].timestamp() | == provenance.storage.directory_get([rd["dst"]])[rd["dst"]].timestamp() | ||||
), synth_rev["msg"] | ), synth_rev["msg"] | ||||
# ... + a number of rows in the "content_in_dir" table | # ... + a number of rows in the "content_in_dir" table | ||||
# for content of the directory. | # for content of the directory. | ||||
# check for D-C entries | # check for D-C entries | ||||
rows["content_in_directory"] |= set( | rows["content_in_directory"] |= set( | ||||
(x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["D_C"] | (x["dst"], x["src"], maybe_path(x["path"])) for x in synth_rev["D_C"] | ||||
) | ) | ||||
assert rows["content_in_directory"] == { | assert rows["content_in_directory"] == { | ||||
(rel.src, rel.dst, rel.path) | (src, rel.dst, rel.path) | ||||
for rel in provenance.storage.relation_get_all(RelationType.CNT_IN_DIR) | for src, rels in provenance.storage.relation_get_all( | ||||
RelationType.CNT_IN_DIR | |||||
).items() | |||||
for rel in rels | |||||
}, synth_rev["msg"] | }, synth_rev["msg"] | ||||
# check timestamps | # check timestamps | ||||
for dc in synth_rev["D_C"]: | for dc in synth_rev["D_C"]: | ||||
assert ( | assert ( | ||||
rev_ts + dc["rel_ts"] | rev_ts + dc["rel_ts"] | ||||
== provenance.storage.content_get([dc["dst"]])[dc["dst"]].timestamp() | == provenance.storage.content_get([dc["dst"]])[dc["dst"]].timestamp() | ||||
), synth_rev["msg"] | ), synth_rev["msg"] | ||||
▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines |