Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/tuleap/tests/test_tasks.py
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
# Copyright (C) 2020 The Software Heritage developers | ||||||||||||
# See the AUTHORS file at the top-level directory of this distribution | ||||||||||||
# License: GNU General Public License version 3, or any later version | ||||||||||||
# See top-level LICENSE file for more information | ||||||||||||
from unittest.mock import patch | ||||||||||||
from swh.lister.pattern import ListerStats | ||||||||||||
def test_ping(swh_scheduler_celery_app, swh_scheduler_celery_worker): | ||||||||||||
res = swh_scheduler_celery_app.send_task("swh.lister.tuleap.tasks.ping") | ||||||||||||
assert res | ||||||||||||
res.wait() | ||||||||||||
assert res.successful() | ||||||||||||
assert res.result == "OK" | ||||||||||||
@patch("swh.lister.tuleap.tasks.TuleapLister") | ||||||||||||
def test_full_listing(lister, swh_scheduler_celery_app, swh_scheduler_celery_worker): | ||||||||||||
ardumont: I do not exactly recall why but now we tend to use the `mocker` fixture instead of the `@patch`… | ||||||||||||
lister.from_configfile.return_value = lister | ||||||||||||
lister.run.return_value = ListerStats(pages=10, origins=500) | ||||||||||||
kwargs = dict(url="https://tuleap.net") | ||||||||||||
res = swh_scheduler_celery_app.send_task( | ||||||||||||
"swh.lister.tuleap.tasks.FullTuleapRelister", kwargs=kwargs, | ||||||||||||
) | ||||||||||||
assert res | ||||||||||||
res.wait() | ||||||||||||
assert res.successful() | ||||||||||||
actual_kwargs = dict(**kwargs, instance=None) | ||||||||||||
lister.from_configfile.assert_called_once_with(**actual_kwargs) | ||||||||||||
ardumontUnsubmitted Done Inline Actions
I got it green by modifying with the ^ You did pass the kwargs to the task (line 26), so that's what's passed to the lister. ardumont: I got it green by modifying with the ^
You did pass the kwargs to the task (line 26), so… | ||||||||||||
borisbaldassariAuthorUnsubmitted Done Inline ActionsHum.. I assumed this test would test the default value for instance, hence the diff. BTW the failing code is present in gitea, where all tests are green :/) As a matter of fact you're right (yeaaah) tests pass with the change, so I'll push it now. Hope I'm not fixing the test without fixing the code... borisbaldassari: Hum.. I assumed this test would test the default value for instance, hence the diff. BTW the… | ||||||||||||
lister.run.assert_called_once_with() | ||||||||||||
@patch("swh.lister.tuleap.tasks.TuleapLister") | ||||||||||||
def test_full_listing_params( | ||||||||||||
lister, swh_scheduler_celery_app, swh_scheduler_celery_worker | ||||||||||||
): | ||||||||||||
lister.from_configfile.return_value = lister | ||||||||||||
lister.run.return_value = ListerStats(pages=10, origins=500) | ||||||||||||
kwargs = dict(url="https://tuleap.net", instance="tuleap.net",) | ||||||||||||
res = swh_scheduler_celery_app.send_task( | ||||||||||||
"swh.lister.tuleap.tasks.FullTuleapRelister", kwargs=kwargs, | ||||||||||||
) | ||||||||||||
assert res | ||||||||||||
res.wait() | ||||||||||||
assert res.successful() | ||||||||||||
lister.from_configfile.assert_called_once_with(**kwargs) | ||||||||||||
lister.run.assert_called_once_with() |
I do not exactly recall why but now we tend to use the mocker fixture instead of the @patch stanza [1]
Can you give it a try?
[1] https://forge.softwareheritage.org/source/swh-lister/browse/master/swh/lister/cgit/tests/test_tasks.py$0-17