swh_config = '/tmp/pytest-of-jenkins/pytest-0/test_npm_loader_incremental_vi0/loader.yml'
requests_mock_datadir_visits = <requests_mock.mocker.Mocker object at 0x7f4435dae780>
def test_npm_loader_incremental_visit(swh_config, requests_mock_datadir_visits):
package = "org"
url = package_url(package)
loader = NpmLoader(url)
actual_load_status = loader.load()
assert actual_load_status["status"] == "eventful"
assert actual_load_status["status"] is not None
assert_last_visit_matches(loader.storage, url, status="full", type="npm")
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": 2,
"release": 0,
"revision": len(_expected_new_revisions_first_visit),
"skipped_content": 0,
"snapshot": 1,
} == stats
loader._info = None # reset loader internal state
actual_load_status2 = loader.load()
assert actual_load_status2["status"] == "eventful"
snap_id2 = actual_load_status2["snapshot_id"]
assert snap_id2 is not None
assert snap_id2 != actual_load_status["snapshot_id"]
> assert_last_visit_matches(loader.storage, url, status="full", type="npm")
.tox/py3/lib/python3.7/site-packages/swh/loader/package/npm/tests/test_npm.py:377:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
storage = <swh.storage.retry.RetryingProxyStorage object at 0x7f443697fa90>
url = 'https://www.npmjs.com/package/org', status = 'full', type = 'npm'
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_and_status = origin_get_latest_visit_status(storage, url)
assert visit_and_status is not None, f"Origin {url} has no visits"
visit, visit_status = visit_and_status
if type:
assert visit.type == type, f"Visit has type {visit.type} instead of {type}"
> assert (
visit_status.status == status
), f"Visit_status has status {visit_status.status} instead of {status}"
E AssertionError: Visit_status has status partial instead of full
E assert 'partial' == 'full'
E - full
E + partial
.tox/py3/lib/python3.7/site-packages/swh/loader/tests/common.py:45: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jun 22 2020, 4:49 PM