swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_2_visits_with_new_artifac0/loader.yml'
requests_mock_datadir = <requests_mock.mocker.Mocker object at 0x7f44372e7c88>
def test_2_visits_with_new_artifact(swh_config, requests_mock_datadir):
"""With no prior visit, load a gnu project ends up with 1 snapshot
"""
url = URL
artifact1 = GNU_ARTIFACTS[0]
loader = ArchiveLoader(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(loader.storage, url, status="full", type="tar")
stats = get_stats(loader.storage)
assert {
"content": len(_expected_new_contents_first_visit),
"directory": len(_expected_new_directories_first_visit),
"origin": 1,
"origin_visit": 1,
"person": 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(url, [artifact1, artifact2])
# implementation detail: share the storage in between visits
loader2.storage = loader.storage
stats2 = get_stats(loader2.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(loader.storage)
assert {
"content": len(_expected_new_contents_first_visit) + 14,
"directory": len(_expected_new_directories_first_visit) + 8,
"origin": 1,
"origin_visit": 1 + 1,
"person": 1,
"release": 0,
"revision": len(_expected_new_revisions_first_visit) + 1,
"skipped_content": 0,
"snapshot": 1 + 1,
} == stats2
assert_last_visit_matches(loader.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:303: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jun 22 2020, 4:49 PM