mocker = <pytest_mock.plugin.MockerFixture object at 0x7fd65b0f7240>
swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7fd65b0f7438>
swh_scheduler_celery_app = <Celery celery.tests at 0x7fd65b014c18>
listed_origins_by_type = {'test-git': [ListedOrigin(lister_id=UUID('298d9d0a-5865-4c6b-be91-576f26935e1e'), url='https://test-git.example.com/0...etime(2020, 6, 15, 16, 0, 0, 1005, tzinfo=datetime.timezone.utc), enabled=True, first_seen=None, last_seen=None), ...]}
extra_cmd_args = ['--lister-name', 'github', '--lister-instance-name', 'github']
@pytest.mark.parametrize(
"extra_cmd_args",
[
[],
["--lister-name", "github", "--lister-instance-name", "github"],
["--environment=staging"],
],
)
def test_schedule_first_visits_cli(
mocker,
swh_scheduler,
swh_scheduler_celery_app,
listed_origins_by_type,
extra_cmd_args,
):
for task_type in TASK_TYPES.values():
swh_scheduler.create_task_type(task_type)
visit_type = next(iter(listed_origins_by_type))
# enabled origins by default except when --staging flag is provided
enabled = "staging" not in extra_cmd_args
# Environment command are for the main command, so massage a bit the flags
if "--environment" in extra_cmd_args:
prefix_cmd_args = extra_cmd_args
extra_cmd_args = []
else:
prefix_cmd_args = []
for origins in listed_origins_by_type.values():
swh_scheduler.record_listed_origins(
(attr.evolve(o, enabled=enabled) for o in origins)
)
get_queue_length = mocker.patch(
"swh.scheduler.celery_backend.config.get_queue_length"
)
get_queue_length.return_value = None
send_task = mocker.patch.object(swh_scheduler_celery_app, "send_task")
send_task.return_value = None
cmd_args = prefix_cmd_args + [
"schedule-first-visits", "--type-name", visit_type
] + extra_cmd_args
result = invoke(swh_scheduler, args=tuple(cmd_args))
assert result.exit_code == 0
scheduled_tasks = {
(call[0][0], call[1]["kwargs"]["url"]) for call in send_task.call_args_list
}
expected_tasks = {
(TASK_TYPES[origin.visit_type]["backend_name"], origin.url)
for origin in listed_origins_by_type[visit_type]
}
> assert expected_tasks == scheduled_tasks
E AssertionError: assert {('swh.loader...m/0005'), ...} == set()
E Extra items in the left set:
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0097')
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0295')
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0632')
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0088')
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0570')
E ('swh.loader.git.tasks.UpdateGitRepository', 'https://test-git.example.com/0048')...
E
E ...Full output truncated (3000 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/scheduler/tests/test_cli_add_forge_now.py:98: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Dec 8 2022, 12:31 PM