swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_cran_2_visits_same_origin0/loader.yml'
requests_mock_datadir = <requests_mock.mocker.Mocker object at 0x7f44372a30b8>
def test_cran_2_visits_same_origin(swh_config, requests_mock_datadir):
"""Multiple visits on the same origin, only 1 archive fetch"""
version = "2.22-6"
base_url = "https://cran.r-project.org"
origin_url = f"{base_url}/Packages/Recommended_KernSmooth/index.html"
artifact_url = (
f"{base_url}/src_contrib_1.4.0_Recommended_KernSmooth_{version}.tar.gz" # noqa
)
loader = CRANLoader(
origin_url, artifacts=[{"url": artifact_url, "version": version}]
)
# first visit
actual_load_status = loader.load()
expected_snapshot_id = "920adcccc78aaeedd3cfa4459dd900d8c3431a21"
assert actual_load_status == {
"status": "eventful",
"snapshot_id": expected_snapshot_id,
}
expected_snapshot = {
"id": expected_snapshot_id,
"branches": {
"HEAD": {"target": f"releases/{version}", "target_type": "alias"},
f"releases/{version}": {
"target": "42bdb16facd5140424359c8ce89a28ecfa1ce603",
"target_type": "revision",
},
},
}
check_snapshot(expected_snapshot, loader.storage)
assert_last_visit_matches(loader.storage, origin_url, status="full", type="cran")
visit_stats = get_stats(loader.storage)
assert {
"content": 33,
"directory": 7,
"origin": 1,
"origin_visit": 1,
"person": 1,
"release": 0,
"revision": 1,
"skipped_content": 0,
"snapshot": 1,
} == visit_stats
# second visit
actual_load_status2 = loader.load()
> assert actual_load_status2 == {
"status": "uneventful",
"snapshot_id": expected_snapshot_id,
}
E AssertionError: assert {'snapshot_id...': 'eventful'} == {'snapshot_id... 'uneventful'}
E Omitting 1 identical items, use -vv to show
E Differing items:
E {'status': 'eventful'} != {'status': 'uneventful'}
E Full diff:
E {
E 'snapshot_id': '920adcccc78aaeedd3cfa4459dd900d8c3431a21',
E - 'status': 'uneventful',...
E
E ...Full output truncated (4 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/loader/package/cran/tests/test_cran.py:264: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jun 22 2020, 4:49 PM