swh_storage = <swh.storage.proxies.retry.RetryingProxyStorage object at 0x7fe861ed87f0>
requests_mock = <requests_mock.mocker.Mocker object at 0x7fe8639f6160>
data_jar_1 = b'PK\x03\x04\n\x00\x00\x08\x08\x00\xba\\\xb7L\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00META-INF/\x...*\x00\x00al/aldi/sprova4j/models/Execution.javaPK\x05\x06\x00\x00\x00\x00#\x00#\x00\xe2\n\x00\x00\xf4,\x00\x00\x00\x00'
def test_jar_visit_with_release_artifact_no_prior_visit(
swh_storage, requests_mock, data_jar_1
):
"""With no prior visit, loading a jar ends up with 1 snapshot
"""
requests_mock.get(MVN_ARTIFACTS[0]["url"], content=data_jar_1)
loader = JarLoader(
swh_storage, MVN_ARTIFACTS[0]["url"], artifacts=[MVN_ARTIFACTS[0]]
)
actual_load_status = loader.load()
print(f"LOAD STATUS {actual_load_status.items()}")
print(f"LOAD STATUS {actual_load_status.keys()}")
# assert actual_load_status["status"] == "eventful"
expected_snapshot_first_visit_id = hash_to_bytes(
"1a8893e6a86f444e8be8e7bda6cb34fb1735a00e"
)
assert (
hash_to_bytes(actual_load_status["snapshot_id"])
== expected_snapshot_first_visit_id
)
print(f"Debug actual load status {actual_load_status}")
stats = get_stats(swh_storage)
print(f"Debug stats {stats}")
> assert_last_visit_matches(swh_storage, URL, status="full", type="jar")
.tox/py3/lib/python3.7/site-packages/swh/loader/package/jar/tests/test_jar.py:138:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
storage = <swh.storage.proxies.retry.RetryingProxyStorage object at 0x7fe861ed87f0>
url = 'https://repo1.maven.org/maven2/', status = 'full', type = 'jar'
snapshot = None
def assert_last_visit_matches(
storage,
url: str,
status: str,
type: Optional[str] = None,
snapshot: Optional[bytes] = None,
) -> OriginVisitStatus:
"""This retrieves the last visit and visit_status which are expected to exist.
This also checks that the {visit|visit_status} have their respective properties
correctly set.
This returns the last visit_status for that given origin.
Args:
url: Origin url
status: Check that the visit status has the given status
type: Check that the returned visit has the given type
snapshot: Check that the visit status points to the given snapshot
Raises:
AssertionError in case visit or visit status is not found, or any of the type,
status and snapshot mismatch
Returns:
the visit status for further check during the remaining part of the test.
"""
visit_status = origin_get_latest_visit_status(storage, url)
> assert visit_status is not None, f"Origin {url} has no visits"
E AssertionError: Origin https://repo1.maven.org/maven2/ has no visits
E assert None is not None
.tox/py3/lib/python3.7/site-packages/swh/loader/tests/__init__.py:48: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Aug 29 2021, 10:24 PM