Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/tests/test_cli.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
def test_get_lister_override(): | def test_get_lister_override(): | ||||
"""Overriding the lister configuration should populate its config | """Overriding the lister configuration should populate its config | ||||
""" | """ | ||||
db_url = init_db().url() | db_url = init_db().url() | ||||
listers = { | listers = { | ||||
'gitlab': ('api_baseurl', 'https://gitlab.uni/api/v4/'), | 'gitlab': 'https://other.gitlab.uni/api/v4/', | ||||
'phabricator': ( | 'phabricator': 'https://somewhere.org/api/diffusion.repository.search', | ||||
'api_baseurl', | 'cgit': 'https://some.where/cgit', | ||||
'https://somewhere.org/api/diffusion.repository.search'), | |||||
} | } | ||||
# check the override ends up defined in the lister | # check the override ends up defined in the lister | ||||
for lister_name, (url_key, url_value) in listers.items(): | for lister_name, url in listers.items(): | ||||
lst = get_lister( | lst = get_lister( | ||||
lister_name, db_url, **{ | lister_name, db_url, **{ | ||||
url_key: url_value, | 'url': url, | ||||
'priority': 'high', | 'priority': 'high', | ||||
'policy': 'oneshot', | 'policy': 'oneshot', | ||||
}) | }) | ||||
assert getattr(lst, url_key) == url_value | assert lst.url == url | ||||
assert lst.config['priority'] == 'high' | assert lst.config['priority'] == 'high' | ||||
assert lst.config['policy'] == 'oneshot' | assert lst.config['policy'] == 'oneshot' | ||||
# check the default urls are used and not the override (since it's not | # check the default urls are used and not the override (since it's not | ||||
# passed) | # passed) | ||||
for lister_name, (url_key, url_value) in listers.items(): | for lister_name, url in listers.items(): | ||||
lst = get_lister(lister_name, db_url) | lst = get_lister(lister_name, db_url) | ||||
# no override so this does not end up in lister's configuration | # no override so this does not end up in lister's configuration | ||||
assert url_key not in lst.config | assert 'url' not in lst.config | ||||
assert 'priority' not in lst.config | assert 'priority' not in lst.config | ||||
assert 'oneshot' not in lst.config | assert 'oneshot' not in lst.config | ||||
assert lst.url == lst.DEFAULT_URL | |||||
def test_task_types(swh_scheduler_config, tmp_path): | def test_task_types(swh_scheduler_config, tmp_path): | ||||
db_url = init_db().url() | db_url = init_db().url() | ||||
configfile = tmp_path / 'config.yml' | configfile = tmp_path / 'config.yml' | ||||
configfile.write_text(yaml.dump({'scheduler': { | configfile.write_text(yaml.dump({'scheduler': { | ||||
'cls': 'local', | 'cls': 'local', | ||||
Show All 36 Lines |