lister = <MagicMock name='GiteaLister' id='140527848488072'>
swh_scheduler_celery_app = <Celery celery.tests at 0x7fcf319f4f98>
swh_scheduler_celery_worker = <Worker: gen370@9f4a28fb3020 (running)>
@patch("swh.lister.gitea.tasks.GiteaLister")
def test_relister_instance(
lister, swh_scheduler_celery_app, swh_scheduler_celery_worker
):
# setup the mocked GiteaLister
lister.return_value = lister
lister.run.return_value = None
lister.get_pages_information.return_value = (None, 85, None)
lister.db_partition_indices.return_value = [
(i, i + 9) for i in range(0, 80, 10)
] + [(80, 85)]
res = swh_scheduler_celery_app.send_task(
"swh.lister.gitea.tasks.FullGiteaRelister",
kwargs=dict(url="https://0xacab.org/api/v4"),
)
assert res
res.wait()
assert res.successful()
# retrieve the GroupResult for this task and wait for all the subtasks
# to complete
promise_id = res.result
assert promise_id
promise = GroupResult.restore(promise_id, app=swh_scheduler_celery_app)
for i in range(5):
if promise.ready():
break
sleep(1)
lister.assert_called_with(url="https://0xacab.org/api/v4")
# one by the FullGiteaRelister task
# + 9 for the RangeGiteaLister subtasks
assert lister.call_count == 10
lister.db_last_index.assert_not_called()
lister.db_partition_indices.assert_not_called()
lister.get_pages_information.assert_called_once_with()
# lister.run should have been called once per partition interval
for i in range(8):
# XXX inconsistent behavior: max_bound is EXCLUDED here
> assert (
dict(min_bound=10 * i, max_bound=10 * i + 10),
) in lister.run.call_args_list
E AssertionError: assert ({'max_bound': 10, 'min_bound': 0},) in [call(max_bound=59, min_bound=50),\n call(max_bound=19, min_bound=10),\n call(max_bound=79, min_bound=70),\n call(max_bou..., min_bound=20),\n call(max_bound=69, min_bound=60),\n call(max_bound=85, min_bound=80),\n call(max_bound=9, min_bound=0)]
E + where [call(max_bound=59, min_bound=50),\n call(max_bound=19, min_bound=10),\n call(max_bound=79, min_bound=70),\n call(max_bou..., min_bound=20),\n call(max_bound=69, min_bound=60),\n call(max_bound=85, min_bound=80),\n call(max_bound=9, min_bound=0)] = <MagicMock name='GiteaLister.run' id='140527848487624'>.call_args_list
E + where <MagicMock name='GiteaLister.run' id='140527848487624'> = <MagicMock name='GiteaLister' id='140527848488072'>.run
.tox/py3/lib/python3.7/site-packages/swh/lister/gitea/tests/test_tasks.py:147: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 9 2020, 7:06 PM