Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/tests/test_provenance_db.py
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | for i in range(2): | ||||
provenance.cursor.execute("SELECT count(*) FROM content_early_in_rev") | provenance.cursor.execute("SELECT count(*) FROM content_early_in_rev") | ||||
assert provenance.cursor.fetchone()[0] == 13 | assert provenance.cursor.fetchone()[0] == 13 | ||||
def test_provenance_content_find_first(provenance, storage_and_CMDBTS, archive): | def test_provenance_content_find_first(provenance, storage_and_CMDBTS, archive): | ||||
storage, data = storage_and_CMDBTS | storage, data = storage_and_CMDBTS | ||||
for revision in data["revision"]: | for revision in data["revision"]: | ||||
entry = RevisionEntry( | entry = RevisionEntry( | ||||
id=revision["id"], date=ts2dt(revision["date"]), root=revision["directory"], | id=revision["id"], | ||||
date=ts2dt(revision["date"]), | |||||
root=revision["directory"], | |||||
) | ) | ||||
revision_add(provenance, archive, entry) | revision_add(provenance, archive, entry) | ||||
first_expected_content = [ | first_expected_content = [ | ||||
{ | { | ||||
"content": "43f3c871310a8e524004e91f033e7fb3b0bc8475", | "content": "43f3c871310a8e524004e91f033e7fb3b0bc8475", | ||||
"rev": "35ccb8dd1b53d2d8a5c1375eb513ef2beaa79ae5", | "rev": "35ccb8dd1b53d2d8a5c1375eb513ef2beaa79ae5", | ||||
"date": 1609757158, | "date": 1609757158, | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | rows = { | ||||
"directory_in_rev": set(), | "directory_in_rev": set(), | ||||
"location": set(), | "location": set(), | ||||
"revision": set(), | "revision": set(), | ||||
} | } | ||||
for synth_rev in synthetic_result(syntheticfile): | for synth_rev in synthetic_result(syntheticfile): | ||||
revision = revisions[synth_rev["sha1"]] | revision = revisions[synth_rev["sha1"]] | ||||
entry = RevisionEntry( | entry = RevisionEntry( | ||||
id=revision["id"], date=ts2dt(revision["date"]), root=revision["directory"], | id=revision["id"], | ||||
date=ts2dt(revision["date"]), | |||||
root=revision["directory"], | |||||
) | ) | ||||
revision_add(provenance, archive, entry, **args) | revision_add(provenance, archive, entry, **args) | ||||
# each "entry" in the synth file is one new revision | # each "entry" in the synth file is one new revision | ||||
rows["revision"].add(synth_rev["sha1"].hex()) | rows["revision"].add(synth_rev["sha1"].hex()) | ||||
assert rows["revision"] == sha1s(provenance.cursor, "revision"), synth_rev[ | assert rows["revision"] == sha1s(provenance.cursor, "revision"), synth_rev[ | ||||
"msg" | "msg" | ||||
] | ] | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |