lister.cli: Clarify configuration loading step
This commit is contained in:
parent
e8a67a7650
commit
eebbc859fc
2 changed files with 13 additions and 14 deletions
|
@ -54,17 +54,15 @@ def lister(ctx, config_file, db_url):
|
|||
from swh.core import config
|
||||
ctx.ensure_object(dict)
|
||||
|
||||
override_conf = {}
|
||||
if not config_file:
|
||||
config_file = os.environ.get('SWH_CONFIG_FILENAME')
|
||||
conf = config.read(config_file)
|
||||
if db_url:
|
||||
override_conf['lister'] = {
|
||||
conf['lister'] = {
|
||||
'cls': 'local',
|
||||
'args': {'db': db_url}
|
||||
}
|
||||
if not config_file:
|
||||
config_file = os.environ.get('SWH_CONFIG_FILENAME')
|
||||
conf = config.read(config_file, override_conf)
|
||||
ctx.obj['config'] = conf
|
||||
ctx.obj['override_conf'] = override_conf
|
||||
|
||||
|
||||
@lister.command(name='db-init', context_settings=CONTEXT_SETTINGS)
|
||||
|
|
|
@ -98,21 +98,22 @@ def test_get_lister_override():
|
|||
|
||||
|
||||
def test_task_types(swh_scheduler_config, tmp_path):
|
||||
db_url = init_db().url()
|
||||
|
||||
configfile = tmp_path / 'config.yml'
|
||||
configfile.write_text(yaml.dump({'scheduler': {
|
||||
'cls': 'local',
|
||||
'args': swh_scheduler_config}}))
|
||||
config = {
|
||||
'scheduler': {
|
||||
'cls': 'local',
|
||||
'args': swh_scheduler_config
|
||||
}
|
||||
}
|
||||
configfile.write_text(yaml.dump(config))
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, [
|
||||
'--db-url', db_url,
|
||||
'--config-file', configfile.as_posix(),
|
||||
'register-task-types'])
|
||||
|
||||
assert result.exit_code == 0, traceback.print_exception(*result.exc_info)
|
||||
|
||||
scheduler = get_scheduler(cls='local', args=swh_scheduler_config)
|
||||
scheduler = get_scheduler(**config['scheduler'])
|
||||
all_tasks = [
|
||||
'list-bitbucket-full', 'list-bitbucket-incremental',
|
||||
'list-cran',
|
||||
|
@ -125,7 +126,7 @@ def test_task_types(swh_scheduler_config, tmp_path):
|
|||
'list-phabricator-full',
|
||||
'list-packagist',
|
||||
'list-pypi',
|
||||
]
|
||||
]
|
||||
for task in all_tasks:
|
||||
task_type_desc = scheduler.get_task_type(task)
|
||||
assert task_type_desc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue