Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/debian/tests/test_tasks.py
# Copyright (C) 2019 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 unittest.mock import patch | ||||
def test_ping(swh_app, celery_session_worker): | def test_ping(swh_app, celery_session_worker): | ||||
res = swh_app.send_task( | res = swh_app.send_task( | ||||
'swh.lister.debian.tasks.ping') | 'swh.lister.debian.tasks.ping') | ||||
assert res | assert res | ||||
res.wait() | res.wait() | ||||
assert res.successful() | assert res.successful() | ||||
assert res.result == 'OK' | assert res.result == 'OK' | ||||
@patch('swh.lister.debian.tasks.DebianLister') | @patch('swh.lister.debian.tasks.DebianLister') | ||||
def test_lister(lister, swh_app, celery_session_worker): | def test_lister(lister, swh_app, celery_session_worker): | ||||
# setup the mocked DebianLister | # setup the mocked DebianLister | ||||
lister.return_value = lister | lister.return_value = lister | ||||
lister.run.return_value = None | lister.run.return_value = None | ||||
res = swh_app.send_task( | res = swh_app.send_task( | ||||
'swh.lister.debian.tasks.DebianListerTask', ('stretch',)) | 'swh.lister.debian.tasks.DebianListerTask', ('stretch',)) | ||||
assert res | assert res | ||||
res.wait() | res.wait() | ||||
assert res.successful() | assert res.successful() | ||||
lister.assert_called_once_with() | lister.assert_called_once_with(distribution='stretch') | ||||
lister.run.assert_called_once_with('stretch') | lister.run.assert_called_once_with() | ||||
ardumont: Shows the distribution is actually passed to the constructor now. | |||||
Done Inline Actionsand no longer to the run method. ardumont: and no longer to the `run` method. |
Shows the distribution is actually passed to the constructor now.