From 446bd2b167c340899c4d81b1e071173648f0f4e2 Mon Sep 17 00:00:00 2001 From: David Douard <david.douard@sdfa3.org> Date: Fri, 23 Apr 2021 17:24:08 +0200 Subject: [PATCH] Fix swh_model_data hardcoded id values and add a test to keep them correct. --- swh/model/tests/swh_model_data.py | 8 ++++---- swh/model/tests/test_swh_model_data.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/swh/model/tests/swh_model_data.py b/swh/model/tests/swh_model_data.py index 0968a7e3..7166522b 100644 --- a/swh/model/tests/swh_model_data.py +++ b/swh/model/tests/swh_model_data.py @@ -120,7 +120,7 @@ REVISIONS = [ ), ), Revision( - id=hash_to_bytes("677063f5c405d6fc1781fc56379c9a9adf43d3a0"), + id=hash_to_bytes("c7f96242d73c267adc77c2908e64e0c1cb6a4431"), message=b"hello again", date=DATES[1], committer=COMMITTERS[1], @@ -261,7 +261,7 @@ ORIGIN_VISIT_STATUSES = [ DIRECTORIES = [ Directory(id=hash_to_bytes("4b825dc642cb6eb9a060e54bf8d69288fbee4904"), entries=()), Directory( - id=hash_to_bytes("21416d920e0ebf0df4a7888bed432873ed5cb3a7"), + id=hash_to_bytes("87b339104f7dc2a8163dec988445e3987995545f"), entries=( DirectoryEntry( name=b"file1.ext", @@ -285,7 +285,7 @@ DIRECTORIES = [ SNAPSHOTS = [ Snapshot( - id=hash_to_bytes("17d0066a4a80aba4a0e913532ee8ff2014f006a9"), + id=hash_to_bytes("9e78d7105c5e0f886487511e2a92377b4ee4c32a"), branches={ b"master": SnapshotBranch( target_type=TargetType.REVISION, target=REVISIONS[0].id @@ -293,7 +293,7 @@ SNAPSHOTS = [ }, ), Snapshot( - id=hash_to_bytes("8ce268b87faf03850693673c3eb5c9bb66e1ca38"), + id=hash_to_bytes("09efffaaad8d1f9c7f9402db0266dbe28082853f"), branches={ b"target/revision": SnapshotBranch( target_type=TargetType.REVISION, target=REVISIONS[0].id, diff --git a/swh/model/tests/test_swh_model_data.py b/swh/model/tests/test_swh_model_data.py index 7b50e60e..3b6cd5cb 100644 --- a/swh/model/tests/test_swh_model_data.py +++ b/swh/model/tests/test_swh_model_data.py @@ -18,6 +18,16 @@ def test_swh_model_data(object_type, objects): attr.validate(obj) +@pytest.mark.parametrize( + "object_type", ("directory", "revision", "release", "snapshot"), +) +def test_swh_model_data_hash(object_type): + for obj in TEST_OBJECTS[object_type]: + assert ( + obj.compute_hash() == obj.id + ), f"{obj.compute_hash().hex()} != {obj.id.hex()}" + + def test_ensure_visit_visit_status_date_consistency(): """ensure origin-visit-status dates are more recent than their visit counterpart -- GitLab