swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f99c040cc88>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f99c040c5c0>
datadir = '/var/lib/jenkins/workspace/DLS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/lister/packagist/tests/data'
requests_mock_datadir = <requests_mock.mocker.Mocker object at 0x7f99c040c5c0>
def test_packagist_lister(swh_scheduler, requests_mock, datadir, requests_mock_datadir):
# first listing, should return one origin per package
lister = PackagistLister(scheduler=swh_scheduler)
requests_mock.get(lister.PACKAGIST_PACKAGES_LIST_URL, json=_packages_list)
packages_metadata = {}
for package_name in _packages_list["packageNames"]:
metadata = _package_metadata(datadir, package_name)
packages_metadata[package_name] = metadata
requests_mock.get(
f"{lister.PACKAGIST_REPO_BASE_URL}/{package_name}.json",
json=metadata,
additional_matcher=_request_without_if_modified_since,
)
stats = lister.run()
assert stats.pages == 1
assert stats.origins == len(_packages_list["packageNames"])
assert lister.updated
expected_origins = {
(
"https://github.com/gitlky/wx_article",
"git",
datetime.datetime.fromisoformat("2018-08-30T07:37:09+00:00"),
),
(
"https://github.com/ljjackson/linnworks",
"git",
datetime.datetime.fromisoformat("2018-11-01T21:45:50+00:00"),
),
(
"https://github.com/spryker-eco/computop-api",
"git",
datetime.datetime.fromisoformat("2020-06-22T15:50:29+00:00"),
),
(
"git@gitlab.com:idevlab/Essential.git",
"git",
datetime.datetime.fromisoformat("2022-10-12T10:34:29+00:00"),
),
}
> assert expected_origins == {
(o.url, o.visit_type, o.last_update)
for o in swh_scheduler.get_listed_origins(lister.lister_obj.id).results
}
E AssertionError: assert {('git@gitlab...imezone.utc))} == {('git@gitlab...imezone.utc))}
E Extra items in the left set:
E ('https://github.com/spryker-eco/computop-api', 'git', datetime.datetime(2020, 6, 22, 15, 50, 29, tzinfo=datetime.timezone.utc))
E Extra items in the right set:
E ('https://github.com/spryker-eco/computop-api.git', 'git', datetime.datetime(2020, 6, 22, 15, 50, 29, tzinfo=datetime.timezone.utc))
E Full diff:
E {
E ('git@gitlab.com:idevlab/Essential.git',...
E
E ...Full output truncated (15 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/lister/packagist/tests/test_lister.py:78: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 13 2022, 4:21 PM