Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/tests/test_init.py
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | def test_check_snapshot_failure(): | ||||
) | ) | ||||
s = storage.snapshot_add([snapshot]) | s = storage.snapshot_add([snapshot]) | ||||
assert s == { | assert s == { | ||||
"snapshot:add": 1, | "snapshot:add": 1, | ||||
} | } | ||||
unexpected_snapshot = { | unexpected_snapshot = { | ||||
"id": "2498dbf535f882bc7f9a18fb16c9ad27fda7bab7", | "id": "2498dbf535f882bc7f9a18fb16c9ad27fda7bab7", # id is correct | ||||
"branches": { | "branches": { | ||||
"master": {"target": hash_hex, "target_type": "release",} # wrong value | "master": {"target": hash_hex, "target_type": "release",} # wrong branch | ||||
}, | }, | ||||
} | } | ||||
with pytest.raises(AssertionError): | with pytest.raises(AssertionError, match="Differing items"): | ||||
check_snapshot(unexpected_snapshot, storage) | |||||
# snapshot id which does not exist | |||||
unexpected_snapshot["id"] = "999666f535f882bc7f9a18fb16c9ad27fda7bab7" | |||||
with pytest.raises(AssertionError, match="is not found"): | |||||
check_snapshot(unexpected_snapshot, storage) | check_snapshot(unexpected_snapshot, storage) |