Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/tests/test_cli.py
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | 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': ('api_baseurl', 'https://gitlab.uni/api/v4/'), | ||||
'phabricator': ('forge_url', 'https://somewhere.org'), | 'phabricator': ('forge_url', 'https://somewhere.org'), | ||||
'cgit': ('url_prefix', 'https://some-cgit.eu/'), | |||||
} | } | ||||
# 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_key, url_value) in listers.items(): | ||||
lst, drop_fn, init_fn, insert_data_fn = get_lister( | lst, drop_fn, init_fn, insert_data_fn = get_lister( | ||||
lister_name, db_url, **{ | lister_name, db_url, **{ | ||||
'api_baseurl': url_value, | 'api_baseurl': url_value, | ||||
'priority': 'high', | 'priority': 'high', | ||||
Show All 9 Lines | def test_get_lister_override(): | ||||
for lister_name, (url_key, url_value) in listers.items(): | for lister_name, (url_key, url_value) in listers.items(): | ||||
lst, drop_fn, init_fn, insert_data_fn = get_lister(lister_name, db_url) | lst, drop_fn, init_fn, insert_data_fn = 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_key not in lst.config | ||||
# then the default base url is used | # then the default base url is used | ||||
default_url = DEFAULT_BASEURLS[lister_name] | default_url = DEFAULT_BASEURLS[lister_name] | ||||
if isinstance(default_url, tuple): # cgit implementation detail... | |||||
default_url = default_url[1] | |||||
assert getattr(lst, url_key) == default_url | assert getattr(lst, url_key) == default_url | ||||
assert 'priority' not in lst.config | assert 'priority' not in lst.config | ||||
assert 'oneshot' not in lst.config | assert 'oneshot' not in lst.config |