Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/tests/test_cli.py
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | for lister_name, url in listers.items(): | ||||
# 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' 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 | 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() | |||||
configfile = tmp_path / 'config.yml' | configfile = tmp_path / 'config.yml' | ||||
configfile.write_text(yaml.dump({'scheduler': { | config = { | ||||
'scheduler': { | |||||
'cls': 'local', | 'cls': 'local', | ||||
'args': swh_scheduler_config}})) | 'args': swh_scheduler_config | ||||
} | |||||
} | |||||
configfile.write_text(yaml.dump(config)) | |||||
runner = CliRunner() | runner = CliRunner() | ||||
result = runner.invoke(cli, [ | result = runner.invoke(cli, [ | ||||
'--db-url', db_url, | |||||
'--config-file', configfile.as_posix(), | '--config-file', configfile.as_posix(), | ||||
'register-task-types']) | 'register-task-types']) | ||||
assert result.exit_code == 0, traceback.print_exception(*result.exc_info) | 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 = [ | all_tasks = [ | ||||
'list-bitbucket-full', 'list-bitbucket-incremental', | 'list-bitbucket-full', 'list-bitbucket-incremental', | ||||
'list-cran', | 'list-cran', | ||||
'list-cgit', | 'list-cgit', | ||||
'list-debian-distribution', | 'list-debian-distribution', | ||||
'list-gitlab-full', 'list-gitlab-incremental', | 'list-gitlab-full', 'list-gitlab-incremental', | ||||
'list-github-full', 'list-github-incremental', | 'list-github-full', 'list-github-incremental', | ||||
'list-gnu-full', | 'list-gnu-full', | ||||
'list-npm-full', 'list-npm-incremental', | 'list-npm-full', 'list-npm-incremental', | ||||
'list-phabricator-full', | 'list-phabricator-full', | ||||
'list-packagist', | 'list-packagist', | ||||
'list-pypi', | 'list-pypi', | ||||
] | ] | ||||
for task in all_tasks: | for task in all_tasks: | ||||
task_type_desc = scheduler.get_task_type(task) | task_type_desc = scheduler.get_task_type(task) | ||||
assert task_type_desc | assert task_type_desc | ||||
assert task_type_desc['type'] == task | assert task_type_desc['type'] == task | ||||
assert task_type_desc['backoff_factor'] == 1 | assert task_type_desc['backoff_factor'] == 1 | ||||
if task == 'list-npm-full': | if task == 'list-npm-full': | ||||
delay = timedelta(days=7) # overloaded in the plugin registry | delay = timedelta(days=7) # overloaded in the plugin registry | ||||
elif task.endswith('-full'): | elif task.endswith('-full'): | ||||
delay = timedelta(days=90) # default value for 'full' lister tasks | delay = timedelta(days=90) # default value for 'full' lister tasks | ||||
else: | else: | ||||
delay = timedelta(days=1) # default value for other lister tasks | delay = timedelta(days=1) # default value for other lister tasks | ||||
assert task_type_desc['default_interval'] == delay, task | assert task_type_desc['default_interval'] == delay, task |