Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/deposit/tests/test_deposit.py
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | def test_revision_metadata_structure(swh_config, requests_mock_datadir): | ||||
url = 'https://hal-test.archives-ouvertes.fr/some-external-id' | url = 'https://hal-test.archives-ouvertes.fr/some-external-id' | ||||
deposit_id = 666 | deposit_id = 666 | ||||
loader = DepositLoader(url, deposit_id) | loader = DepositLoader(url, deposit_id) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status['status'] == 'eventful' | assert actual_load_status['status'] == 'eventful' | ||||
assert actual_load_status['snapshot_id'] is not None | assert actual_load_status['snapshot_id'] is not None | ||||
expected_revision_id = hash_to_bytes( | expected_revision_id = hash_to_bytes( | ||||
'9471c606239bccb1f269564c9ea114e1eeab9eb4') | '637318680351f5d78856d13264faebbd91efe9bb') | ||||
revision = list(loader.storage.revision_get([expected_revision_id]))[0] | revision = list(loader.storage.revision_get([expected_revision_id]))[0] | ||||
assert revision is not None | assert revision is not None | ||||
check_metadata_paths(revision['metadata'], paths=[ | check_metadata_paths(revision['metadata'], paths=[ | ||||
('extrinsic.provider', str), | ('extrinsic.provider', str), | ||||
('extrinsic.when', str), | ('extrinsic.when', str), | ||||
('extrinsic.raw', dict), | ('extrinsic.raw', dict), | ||||
Show All 11 Lines | |||||
def test_deposit_loading_ok(swh_config, requests_mock_datadir): | def test_deposit_loading_ok(swh_config, requests_mock_datadir): | ||||
requests_mock_datadir.put(re.compile('https')) # do not care for put | requests_mock_datadir.put(re.compile('https')) # do not care for put | ||||
url = 'https://hal-test.archives-ouvertes.fr/some-external-id' | url = 'https://hal-test.archives-ouvertes.fr/some-external-id' | ||||
deposit_id = 666 | deposit_id = 666 | ||||
loader = DepositLoader(url, deposit_id) | loader = DepositLoader(url, deposit_id) | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
expected_snapshot_id = '453f455d0efb69586143cd6b6e5897f9906b53a7' | expected_snapshot_id = 'b2b327b33dc85818bd23c3ccda8b7e675a66ecbd' | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
'status': 'eventful', | 'status': 'eventful', | ||||
'snapshot_id': expected_snapshot_id, | 'snapshot_id': expected_snapshot_id, | ||||
} | } | ||||
stats = get_stats(loader.storage) | stats = get_stats(loader.storage) | ||||
assert { | assert { | ||||
'content': 303, | 'content': 303, | ||||
'directory': 12, | 'directory': 12, | ||||
'origin': 1, | 'origin': 1, | ||||
'origin_visit': 1, | 'origin_visit': 1, | ||||
'person': 1, | 'person': 1, | ||||
'release': 0, | 'release': 0, | ||||
'revision': 1, | 'revision': 1, | ||||
'skipped_content': 0, | 'skipped_content': 0, | ||||
'snapshot': 1, | 'snapshot': 1, | ||||
} == stats | } == stats | ||||
origin_visit = next(loader.storage.origin_visit_get(url)) | origin_visit = next(loader.storage.origin_visit_get(url)) | ||||
assert origin_visit['status'] == 'full' | assert origin_visit['status'] == 'full' | ||||
assert origin_visit['type'] == 'deposit' | assert origin_visit['type'] == 'deposit' | ||||
expected_branches = { | expected_branches = { | ||||
'HEAD': { | 'HEAD': { | ||||
'target': '9471c606239bccb1f269564c9ea114e1eeab9eb4', | 'target': '637318680351f5d78856d13264faebbd91efe9bb', | ||||
'target_type': 'revision', | 'target_type': 'revision', | ||||
}, | }, | ||||
} | } | ||||
expected_snapshot = { | expected_snapshot = { | ||||
'id': expected_snapshot_id, | 'id': expected_snapshot_id, | ||||
'branches': expected_branches, | 'branches': expected_branches, | ||||
} | } | ||||
Show All 37 Lines |