Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cgit/tests/test_lister.py
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | load_from_envvar.return_value = { | ||||
"scheduler": {"cls": "local", **swh_scheduler_config}, | "scheduler": {"cls": "local", **swh_scheduler_config}, | ||||
"url": "https://git.tizen/cgit/", | "url": "https://git.tizen/cgit/", | ||||
"instance": "tizen", | "instance": "tizen", | ||||
"credentials": {}, | "credentials": {}, | ||||
} | } | ||||
lister = CGitLister.from_configfile() | lister = CGitLister.from_configfile() | ||||
assert lister.scheduler is not None | assert lister.scheduler is not None | ||||
assert lister.credentials is not None | assert lister.credentials is not None | ||||
anlambert: maybe you could parametrize the test with more URLs (using edge case URLs listed in T2999). | |||||
Done Inline Actionsok, but that means more html sample files in that diff (currenty adding one other origin) ardumont: ok, but that means more html sample files in that diff (currenty adding one other origin) | |||||
Not Done Inline ActionsAh right, you could isolate the code to compute URLs in a method and only test that then. anlambert: Ah right, you could isolate the code to compute URLs in a method and only test that then. | |||||
Done Inline Actionswell, it's done now ¯\_(ツ)_/¯ :) ardumont: well, it's done now ¯\_(ツ)_/¯ :) | |||||
def test_lister_cgit_with_base_git_url(requests_mock_datadir, swh_scheduler): | |||||
"""With base git url provided, listed urls should be the computed origin urls | |||||
""" | |||||
url = "https://git.eclipse.org/c" | |||||
Done Inline Actionsnot that important but i meant it as /r here ;) ardumont: not that important but i meant it as `/r` here ;) | |||||
base_git_url = "https://eclipse.org/c" | |||||
lister_cgit = CGitLister(swh_scheduler, url=url, base_git_url=base_git_url,) | |||||
stats = lister_cgit.run() | |||||
expected_nb_origins = 5 # 5 "sublevel-section" class in html | |||||
assert stats == ListerStats(pages=1, origins=expected_nb_origins) | |||||
# test page parsing | |||||
scheduler_origins = swh_scheduler.get_listed_origins( | |||||
lister_cgit.lister_obj.id | |||||
).results | |||||
assert len(scheduler_origins) == expected_nb_origins | |||||
# test listed repositories | |||||
for listed_origin in scheduler_origins: | |||||
assert listed_origin.visit_type == "git" | |||||
assert listed_origin.url.startswith(base_git_url) |
maybe you could parametrize the test with more URLs (using edge case URLs listed in T2999).