commit 0dd744df1d1192d4eeb3fbe38c96cce76bda7376 from: Antoine Lambert date: Tue Sep 10 15:25:01 2024 UTC tests: Fix numerous tests after recent changes in loader-core BaseLoader.load now returns a dict with an extra error field when a loading fails. commit - 48d0acfaa13b01fa5b9dd9d9ea42ffdfb7daf86d commit + 0dd744df1d1192d4eeb3fbe38c96cce76bda7376 blob - 4f4e8713c010b4e1b5e1f5c0bb4804ae25c80865 blob + 2daba7aa61853d96b5281644377e0cd9679a33a5 --- swh/loader/git/tests/test_directory.py +++ swh/loader/git/tests/test_directory.py @@ -227,7 +227,7 @@ def test_loader_git_directory_hash_mismatch(swh_storag actual_result = loader.load() # Ingestion fails because the checks failed - assert actual_result == {"status": "failed"} + assert actual_result["status"] == "failed" assert get_stats(swh_storage) == { "content": 0, "directory": 0, blob - 1de43661b1901398d3fdfde9346b9764a9c75252 blob + b4191278134487036b84dbfa52f06b53008a9dcc --- swh/loader/git/tests/test_from_disk.py +++ swh/loader/git/tests/test_from_disk.py @@ -183,7 +183,7 @@ class CommonGitLoaderTests: self.loader.get_contents = None res = self.loader.load() - assert res == {"status": "failed"} + assert res["status"] == "failed" assert_last_visit_matches( self.loader.storage, @@ -205,7 +205,7 @@ class CommonGitLoaderTests: ) res = self.loader.load() - assert res == {"status": "failed"} + assert res["status"] == "failed" assert_last_visit_matches( self.loader.storage, blob - f54b16e13cf779f20295f583fb3e56deec775b9b blob + 41fa0d5e23df5b567ffb87534e22a349ae122995 --- swh/loader/git/tests/test_loader.py +++ swh/loader/git/tests/test_loader.py @@ -109,7 +109,7 @@ class CommonGitLoaderNotFound: mock.side_effect = failure_exception res = self.loader.load() - assert res == {"status": "failed"} + assert res["status"] == "failed" assert_last_visit_matches( self.loader.storage, @@ -405,11 +405,11 @@ class TestGitLoader(FullGitLoaderTests, CommonGitLoade corrupted_release = attr.evolve(release, id=b"\x00" * 20) release_get = mocker.patch.object(self.loader.storage, "release_get") release_get.return_value = [corrupted_release] - assert self.loader.load() == {"status": "failed"} + assert self.loader.load()["status"] == "failed" elif missing_object: revision_get = mocker.patch.object(self.loader.storage, "revision_get") revision_get.return_value = [None] - assert self.loader.load() == {"status": "failed"} + assert self.loader.load()["status"] == "failed" assert list( sorted( [c for c in statsd_calls if c[1][0] == statsd_metric], @@ -457,7 +457,7 @@ class TestGitLoader(FullGitLoaderTests, CommonGitLoade # set max pack size to a really small value self.loader.pack_size_bytes = 10 res = self.loader.load() - assert res == {"status": "failed"} + assert res["status"] == "failed" assert sentry_events assert sentry_events[0]["level"] == "error" assert sentry_events[0]["exception"]["values"][0]["value"].startswith( @@ -1063,7 +1063,7 @@ class TestDumbGitLoaderWithPack(DumbGitLoaderTestBase) # set max pack size to a really small value self.loader.pack_size_bytes = 10 res = self.loader.load() - assert res == {"status": "failed"} + assert res["status"] == "failed" assert sentry_events assert sentry_events[0]["level"] == "error" assert sentry_events[0]["exception"]["values"][0]["value"].startswith( @@ -1121,7 +1121,7 @@ def test_loader_too_large_pack_file_for_github_origin( return_value=[metadata], ) - assert loader.load() == {"status": "failed"} + assert loader.load()["status"] == "failed" assert sentry_events assert sentry_events[0]["level"] == "error"