diff --git a/swh/loader/git/tests/test_loader.py b/swh/loader/git/tests/test_loader.py --- a/swh/loader/git/tests/test_loader.py +++ b/swh/loader/git/tests/test_loader.py @@ -10,7 +10,7 @@ from swh.loader.git.loader import GitLoader, GitLoaderFromArchive from swh.loader.core.tests import BaseLoaderTest, LoaderNoStorage -from swh.model.hashutil import hash_to_bytes +from swh.model.hashutil import hash_to_bytes, hash_to_bytehex class MockStorage0: @@ -27,6 +27,9 @@ def revision_missing(self, revisions): return revisions + def object_find_by_sha1_git(self, ids): + return {} + CONTENT1 = { '33ab5639bfd8e7b95eb1d8d0b87781d4ffea4d5d', # README v1 @@ -131,6 +134,42 @@ assert all(isinstance(r, bytes) for r in revisions) return list(set(revisions) - set(map(hash_to_bytes, REVISIONS1))) + def object_find_by_sha1_git(self, ids): + res = {} + for id_ in ids: + found = [] + decoded_id = hash_to_bytehex(id_) + if decoded_id in REVISIONS1: + found.append({ + 'sha1_git': id_, + 'type': 'revision', + 'id': id_, + 'object_id': 42, + }) + elif decoded_id in REVISIONS1.values(): + found.append({ + 'sha1_git': id_, + 'type': 'directory', + 'id': id_, + 'object_id': 42, + }) + elif decoded_id == SUBDIR_HASH: + found.append({ + 'sha1_git': id_, + 'type': 'directory', + 'id': id_, + 'object_id': 42, + }) + elif decoded_id in CONTENT1: + found.append({ + 'sha1_git': id_, + 'type': 'content', + 'id': id_, + 'object_id': 42, + }) + res[id_] = found + return res + class LoaderNoStorageMixin(LoaderNoStorage): def __init__(self): diff --git a/swh/loader/git/tests/test_updater.py b/swh/loader/git/tests/test_updater.py new file mode 100644 --- /dev/null +++ b/swh/loader/git/tests/test_updater.py @@ -0,0 +1,17 @@ +from swh.loader.git.updater import BulkUpdater +from swh.loader.git.tests.test_loader import ( + DirGitLoaderTest, LoaderNoStorageMixin) + + +class BulkUpdaterNoStorage(LoaderNoStorageMixin, BulkUpdater): + pass + + +class BulkUpdaterTest(DirGitLoaderTest): + def setUp(self): + super().setUp() + self.loader = BulkUpdaterNoStorage() + + def load(self): + return self.loader.load( + origin_url=self.repo_url)