Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/tests/test_from_disk.py
Show First 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | |||||
class GitLoaderFromDiskTest(TestCase, FullGitLoaderTests): | class GitLoaderFromDiskTest(TestCase, FullGitLoaderTests): | ||||
"""Prepare a git directory repository to be loaded through a GitLoaderFromDisk. | """Prepare a git directory repository to be loaded through a GitLoaderFromDisk. | ||||
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): | ||||
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 = GitLoaderFromDisk( | self.loader = GitLoaderFromDisk( | ||||
swh_storage, | |||||
url=self.repo_url, | url=self.repo_url, | ||||
visit_date=datetime.datetime( | visit_date=datetime.datetime( | ||||
2016, 5, 3, 15, 16, 32, tzinfo=datetime.timezone.utc | 2016, 5, 3, 15, 16, 32, tzinfo=datetime.timezone.utc | ||||
), | ), | ||||
directory=self.destination_path, | directory=self.destination_path, | ||||
) | ) | ||||
self.repo = dulwich.repo.Repo(self.destination_path) | self.repo = dulwich.repo.Repo(self.destination_path) | ||||
class GitLoaderFromArchiveTest(TestCase, CommonGitLoaderTests): | class GitLoaderFromArchiveTest(TestCase, CommonGitLoaderTests): | ||||
"""Tests for GitLoaderFromArchive. Only tests common scenario.""" | """Tests for GitLoaderFromArchive. Only tests common 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): | ||||
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") | ||||
self.repo_url = archive_path | self.repo_url = archive_path | ||||
self.loader = GitLoaderFromArchive( | self.loader = GitLoaderFromArchive( | ||||
swh_storage, | |||||
url=self.repo_url, | url=self.repo_url, | ||||
archive_path=archive_path, | archive_path=archive_path, | ||||
visit_date=datetime.datetime( | visit_date=datetime.datetime( | ||||
2016, 5, 3, 15, 16, 32, tzinfo=datetime.timezone.utc | 2016, 5, 3, 15, 16, 32, tzinfo=datetime.timezone.utc | ||||
), | ), | ||||
) | ) |