swh_storage = <swh.storage.retry.RetryingProxyStorage object at 0x7faf15de9f98>
requests_mock_datadir = <requests_mock.mocker.Mocker object at 0x7faf15e346a0>
def test_archive_2_visits_with_new_artifact(swh_storage, requests_mock_datadir):
"""With no prior visit, load a gnu project ends up with 1 snapshot
"""
url = URL
artifact1 = GNU_ARTIFACTS[0]
loader = ArchiveLoader(swh_storage, url, [artifact1])
actual_load_status = loader.load()
assert actual_load_status["status"] == "eventful"
assert actual_load_status["snapshot_id"] is not None
assert_last_visit_matches(swh_storage, url, status="full", type="tar")
stats = get_stats(swh_storage)
assert {
"content": len(_expected_new_contents_first_visit),
"directory": len(_expected_new_directories_first_visit),
"origin": 1,
"origin_visit": 1,
"release": 0,
"revision": len(_expected_new_revisions_first_visit),
"skipped_content": 0,
"snapshot": 1,
} == stats
urls = [
m.url
for m in requests_mock_datadir.request_history
if m.url.startswith("https://ftp.gnu.org")
]
assert len(urls) == 1
artifact2 = {
"time": 1480991830,
"url": "https://ftp.gnu.org/gnu/8sync/8sync-0.2.0.tar.gz",
"length": 238466,
"filename": "8sync-0.2.0.tar.gz",
"version": "0.2.0",
}
loader2 = ArchiveLoader(swh_storage, url, [artifact1, artifact2])
stats2 = get_stats(swh_storage)
assert stats == stats2 # ensure we share the storage
actual_load_status2 = loader2.load()
assert actual_load_status2["status"] == "eventful"
assert actual_load_status2["snapshot_id"] is not None
stats2 = get_stats(swh_storage)
assert {
"content": len(_expected_new_contents_first_visit) + 14,
"directory": len(_expected_new_directories_first_visit) + 8,
"origin": 1,
"origin_visit": 1 + 1,
"release": 0,
"revision": len(_expected_new_revisions_first_visit) + 1,
"skipped_content": 0,
"snapshot": 1 + 1,
} == stats2
assert_last_visit_matches(swh_storage, url, status="full", type="tar")
urls = [
m.url
for m in requests_mock_datadir.request_history
if m.url.startswith("https://ftp.gnu.org")
]
# 1 artifact (2nd time no modification) + 1 new artifact
> assert len(urls) == 2
E assert 3 == 2
E +3
E -2
.tox/py3/lib/python3.7/site-packages/swh/loader/package/archive/tests/test_archive.py:300: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Mar 19 2021, 2:32 PM