Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
Show First 20 Lines • Show All 797 Lines • ▼ Show 20 Lines | def test_svn_loader_from_remote_dump(swh_storage, datadir, tmp_path): | ||||
# second visit from the dump should be uneventful | # second visit from the dump should be uneventful | ||||
loaderFromDump = SvnLoaderFromRemoteDump( | loaderFromDump = SvnLoaderFromRemoteDump( | ||||
swh_storage, repo_url, temp_directory=tmp_path | swh_storage, repo_url, temp_directory=tmp_path | ||||
) | ) | ||||
assert loaderFromDump.load() == {"status": "uneventful"} | assert loaderFromDump.load() == {"status": "uneventful"} | ||||
def test_svn_loader_from_remote_dump_multiple_load_on_stale_repo( | def test_svn_loader_from_remote_dump_incremental_load_on_stale_repo( | ||||
swh_storage, datadir, tmp_path, mocker | swh_storage, datadir, tmp_path, mocker | ||||
): | ): | ||||
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) | ||||
# first load: a dump file will be created, mounted to a local repository | # first load: a dump file will be created, mounted to a local repository | ||||
# and the latter will be loaded into the archive | # and the latter will be loaded into the archive | ||||
Show All 36 Lines | ): | ||||
# no mount | # no mount | ||||
init_svn_repo_from_dump.assert_not_called() | init_svn_repo_from_dump.assert_not_called() | ||||
# no loading | # no loading | ||||
loaderFromDump.process_svn_revisions.assert_not_called() | loaderFromDump.process_svn_revisions.assert_not_called() | ||||
# no redundant post_load processing | # no redundant post_load processing | ||||
loaderFromDump._check_revision_divergence.assert_not_called() | loaderFromDump._check_revision_divergence.assert_not_called() | ||||
def test_svn_loader_from_remote_dump_incremental_load_on_non_stale_repo( | |||||
swh_storage, datadir, tmp_path, mocker | |||||
): | |||||
archive_name = "pkg-gourmet" | |||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | |||||
repo_url = prepare_repository_from_archive(archive_path, archive_name, tmp_path) | |||||
# first load | |||||
loader = SvnLoaderFromRemoteDump(swh_storage, repo_url, temp_directory=tmp_path) | |||||
loader.load() | |||||
archive_path = os.path.join(datadir, "pkg-gourmet-with-updates.tgz") | |||||
repo_updated_url = prepare_repository_from_archive( | |||||
archive_path, archive_name, tmp_path | |||||
) | |||||
# second load | |||||
loader = SvnLoaderFromRemoteDump( | |||||
swh_storage, repo_updated_url, temp_directory=tmp_path | |||||
) | |||||
dump_svn_revisions = mocker.spy(loader, "dump_svn_revisions") | |||||
process_svn_revisions = mocker.spy(loader, "process_svn_revisions") | |||||
loader.load() | |||||
dump_svn_revisions.assert_called() | |||||
process_svn_revisions.assert_called() | |||||
def test_loader_user_defined_svn_properties(swh_storage, datadir, tmp_path): | def test_loader_user_defined_svn_properties(swh_storage, datadir, tmp_path): | ||||
"""Edge cases: The repository held some user defined svn-properties with special | """Edge cases: The repository held some user defined svn-properties with special | ||||
encodings, this prevented the repository from being loaded even though we do not | encodings, this prevented the repository from being loaded even though we do not | ||||
ingest those information. | ingest those information. | ||||
""" | """ | ||||
archive_name = "httthttt" | archive_name = "httthttt" | ||||
archive_path = os.path.join(datadir, f"{archive_name}.tgz") | archive_path = os.path.join(datadir, f"{archive_name}.tgz") | ||||
▲ Show 20 Lines • Show All 664 Lines • Show Last 20 Lines |