Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/tests/test_loader.py
Show All 15 Lines | |||||
from swh.loader.git.loader import GitLoader | from swh.loader.git.loader import GitLoader | ||||
from swh.loader.git.tests.test_from_disk import FullGitLoaderTests | from swh.loader.git.tests.test_from_disk import FullGitLoaderTests | ||||
from swh.loader.tests import ( | from swh.loader.tests import ( | ||||
assert_last_visit_matches, | assert_last_visit_matches, | ||||
get_stats, | get_stats, | ||||
prepare_repository_from_archive, | prepare_repository_from_archive, | ||||
) | ) | ||||
from swh.storage.algos.origin import origin_get_latest_visit_status | |||||
class CommonGitLoaderNotFound: | class CommonGitLoaderNotFound: | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | ||||
def __inject_fixtures(self, mocker): | def __inject_fixtures(self, mocker): | ||||
"""Inject required fixtures in unittest.TestCase class | """Inject required fixtures in unittest.TestCase class | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | def test_load_visit_failure(self, failure_exception): | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
self.loader.storage, | self.loader.storage, | ||||
self.repo_url, | self.repo_url, | ||||
status="failed", | status="failed", | ||||
type="git", | type="git", | ||||
snapshot=None, | snapshot=None, | ||||
) | ) | ||||
def test_load_visit_multiple_times(self): | |||||
"""Ingesting repositories in multiple packfiles should be ok | |||||
""" | |||||
# Make the loader retrieve multiple packfiles | |||||
self.loader.packfile_chunk_size = 3 | |||||
res = self.loader.load() | |||||
assert res == {"status": "eventful"} | |||||
stats = get_stats(self.loader.storage) | |||||
assert stats == { | |||||
"content": 4, | |||||
"directory": 7, | |||||
"origin": 1, | |||||
"origin_visit": 1, | |||||
"release": 0, | |||||
"revision": 7, | |||||
"skipped_content": 0, | |||||
"snapshot": 1 + 1, # one partial snapshot and one final | |||||
} | |||||
partial_visit = origin_get_latest_visit_status( | |||||
self.loader.storage, self.repo_url, type="git", allowed_statuses=["partial"] | |||||
) | |||||
assert partial_visit is not None | |||||
assert partial_visit.snapshot is not None | |||||
# Final status is ok | |||||
visit_status = assert_last_visit_matches( | |||||
self.loader.storage, self.repo_url, status="full", type="git", | |||||
) | |||||
assert visit_status.snapshot is not None | |||||
class TestGitLoader(FullGitLoaderTests, CommonGitLoaderNotFound): | class TestGitLoader(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) | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |