Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show All 35 Lines | branches={ | ||||
target_type=TargetType.REVISION, | target_type=TargetType.REVISION, | ||||
) | ) | ||||
}, | }, | ||||
) | ) | ||||
def test_loader_svn_not_found_no_mock(swh_storage, tmp_path): | def test_loader_svn_not_found_no_mock(swh_storage, tmp_path): | ||||
"""Given an unknown repository, the loader visit ends up in status not_found""" | """Given an unknown repository, the loader visit ends up in status not_found""" | ||||
unknown_repo_url = "unknown-repository" | repo_url = "unknown-repository" | ||||
loader = SvnLoader(swh_storage, unknown_repo_url, destination_path=tmp_path) | loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) | ||||
assert loader.load() == {"status": "uneventful"} | assert loader.load() == {"status": "uneventful"} | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, unknown_repo_url, status="not_found", type="svn", | swh_storage, repo_url, status="not_found", type="svn", | ||||
) | ) | ||||
@pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||
"exception_msg", ["Unable to connect to a repository at URL", "Unknown URL type",] | "exception_msg", ["Unable to connect to a repository at URL", "Unknown URL type",] | ||||
) | ) | ||||
def test_loader_svn_not_found(swh_storage, tmp_path, exception_msg, mocker): | def test_loader_svn_not_found(swh_storage, tmp_path, exception_msg, mocker): | ||||
"""Given unknown repository issues, the loader visit ends up in status not_found""" | """Given unknown repository issues, the loader visit ends up in status not_found""" | ||||
Show All 28 Lines | def test_loader_svn_failures(swh_storage, tmp_path, exception, mocker): | ||||
assert loader.load() == {"status": "failed"} | assert loader.load() == {"status": "failed"} | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, existing_repo_url, status="failed", type="svn", | swh_storage, existing_repo_url, status="failed", type="svn", | ||||
) | ) | ||||
def test_loader_svnrdump_not_found(swh_storage, tmp_path, mocker): | |||||
"""Loading from remote dump which does not exist should end up as not_found visit""" | |||||
unknown_repo_url = "file:///tmp/svn.code.sf.net/p/white-rats-studios/svn" | |||||
loader = SvnLoaderFromRemoteDump( | |||||
anlambert: To remove I guess. | |||||
Done Inline Actionsyes, it's done locally, i forgot to update the diff. ardumont: yes, it's done locally, i forgot to update the diff. | |||||
swh_storage, unknown_repo_url, destination_path=tmp_path | |||||
) | |||||
assert loader.load() == {"status": "uneventful"} | |||||
assert_last_visit_matches( | |||||
swh_storage, unknown_repo_url, status="not_found", type="svn", | |||||
) | |||||
def test_loader_svn_new_visit(swh_storage, datadir, tmp_path): | def test_loader_svn_new_visit(swh_storage, datadir, tmp_path): | ||||
"""Eventful visit should yield 1 snapshot""" | """Eventful visit should yield 1 snapshot""" | ||||
archive_name = "pkg-gourmet" | archive_name = "pkg-gourmet" | ||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | ||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | ||||
loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) | loader = SvnLoader(swh_storage, repo_url, destination_path=tmp_path) | ||||
Show All 23 Lines | |||||
def test_loader_svn_2_visits_no_change(swh_storage, datadir, tmp_path): | def test_loader_svn_2_visits_no_change(swh_storage, datadir, tmp_path): | ||||
"""Visit multiple times a repository with no change should yield the same snapshot | """Visit multiple times a repository with no change should yield the same snapshot | ||||
""" | """ | ||||
archive_name = "pkg-gourmet" | archive_name = "pkg-gourmet" | ||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | ||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | ||||
Done Inline ActionsNot sure if that variable should have been renamed in all other tests. anlambert: Not sure if that variable should have been renamed in all other tests. | |||||
Done Inline Actionsoh no, right ;) ardumont: oh no, right ;) | |||||
loader = SvnLoader(swh_storage, repo_url) | loader = SvnLoader(swh_storage, repo_url) | ||||
assert loader.load() == {"status": "eventful"} | assert loader.load() == {"status": "eventful"} | ||||
visit_status1 = assert_last_visit_matches( | visit_status1 = assert_last_visit_matches( | ||||
loader.storage, | loader.storage, | ||||
repo_url, | repo_url, | ||||
status="full", | status="full", | ||||
▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines |
To remove I guess.