Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/tests/test_loader.py
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
class GitLoaderTest(TestCase, FullGitLoaderTests, CommonGitLoaderNotFound): | class GitLoaderTest(TestCase, FullGitLoaderTests, CommonGitLoaderNotFound): | ||||
"""Prepare a git directory repository to be loaded through a GitLoader. | """Prepare a git directory repository to be loaded through a GitLoader. | ||||
This tests all git loader scenario. | This tests all git loader scenario. | ||||
""" | """ | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | ||||
def init(self, swh_config, datadir, tmp_path): | def init(self, swh_storage, datadir, tmp_path): | ||||
super().setUp() | super().setUp() | ||||
archive_name = "testrepo" | archive_name = "testrepo" | ||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | ||||
tmp_path = str(tmp_path) | tmp_path = str(tmp_path) | ||||
self.repo_url = prepare_repository_from_archive( | self.repo_url = prepare_repository_from_archive( | ||||
archive_path, archive_name, tmp_path=tmp_path | archive_path, archive_name, tmp_path=tmp_path | ||||
) | ) | ||||
self.destination_path = os.path.join(tmp_path, archive_name) | self.destination_path = os.path.join(tmp_path, archive_name) | ||||
self.loader = GitLoader(self.repo_url) | self.loader = GitLoader(swh_storage, self.repo_url) | ||||
self.repo = dulwich.repo.Repo(self.destination_path) | self.repo = dulwich.repo.Repo(self.destination_path) | ||||
class GitLoader2Test(TestCase, FullGitLoaderTests, CommonGitLoaderNotFound): | class GitLoader2Test(TestCase, FullGitLoaderTests, CommonGitLoaderNotFound): | ||||
"""Mostly the same loading scenario but with a base-url different than the repo-url. | """Mostly the same loading scenario but with a base-url different than the repo-url. | ||||
To walk slightly different paths, the end result should stay the same. | To walk slightly different paths, the end result should stay the same. | ||||
""" | """ | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | ||||
def init(self, swh_loader_config, datadir, tmp_path): | def init(self, swh_storage, datadir, tmp_path): | ||||
super().setUp() | super().setUp() | ||||
archive_name = "testrepo" | archive_name = "testrepo" | ||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | ||||
tmp_path = str(tmp_path) | tmp_path = str(tmp_path) | ||||
self.repo_url = prepare_repository_from_archive( | self.repo_url = prepare_repository_from_archive( | ||||
archive_path, archive_name, tmp_path=tmp_path | archive_path, archive_name, tmp_path=tmp_path | ||||
) | ) | ||||
self.destination_path = os.path.join(tmp_path, archive_name) | self.destination_path = os.path.join(tmp_path, archive_name) | ||||
base_url = f"base://{self.repo_url}" | base_url = f"base://{self.repo_url}" | ||||
self.loader = GitLoader( | self.loader = GitLoader(swh_storage, self.repo_url, base_url=base_url) | ||||
self.repo_url, base_url=base_url, config=swh_loader_config | |||||
) | |||||
self.repo = dulwich.repo.Repo(self.destination_path) | self.repo = dulwich.repo.Repo(self.destination_path) |