Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_cli.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | def fill_idx_storage(idx_storage, nb_rows): | ||||
idx_storage.revision_intrinsic_metadata_add(revision_metadata) | idx_storage.revision_intrinsic_metadata_add(revision_metadata) | ||||
idx_storage.origin_intrinsic_metadata_add(origin_metadata) | idx_storage.origin_intrinsic_metadata_add(origin_metadata) | ||||
return [tool['id'] for tool in tools] | return [tool['id'] for tool in tools] | ||||
def _origins_in_task_args(tasks): | def _origins_in_task_args(tasks): | ||||
"""Returns the set of origins contained in the arguments of the | """Returns the set of origins contained in the arguments of the | ||||
provided tasks (assumed to be of type indexer_origin_metadata).""" | provided tasks (assumed to be of type index-origin-metadata).""" | ||||
return reduce( | return reduce( | ||||
set.union, | set.union, | ||||
(set(task['arguments']['args'][0]) for task in tasks), | (set(task['arguments']['args'][0]) for task in tasks), | ||||
set() | set() | ||||
) | ) | ||||
def _assert_tasks_for_origins(tasks, origins): | def _assert_tasks_for_origins(tasks, origins): | ||||
expected_kwargs = {"policy_update": "update-dups", "parse_ids": False} | expected_kwargs = {"policy_update": "update-dups", "parse_ids": False} | ||||
assert {task['type'] for task in tasks} == {'indexer_origin_metadata'} | assert {task['type'] for task in tasks} == {'index-origin-metadata'} | ||||
assert all(len(task['arguments']['args']) == 1 for task in tasks) | assert all(len(task['arguments']['args']) == 1 for task in tasks) | ||||
assert all(task['arguments']['kwargs'] == expected_kwargs | assert all(task['arguments']['kwargs'] == expected_kwargs | ||||
for task in tasks) | for task in tasks) | ||||
assert _origins_in_task_args(tasks) == set(origins) | assert _origins_in_task_args(tasks) == set(origins) | ||||
def invoke(scheduler, catch_exceptions, args): | def invoke(scheduler, catch_exceptions, args): | ||||
runner = CliRunner() | runner = CliRunner() | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |