Add tests for pypi tasks
This commit is contained in:
parent
f63b8326c5
commit
65f3b9edc8
4 changed files with 29 additions and 0 deletions
0
swh/lister/pypi/tests/__init__.py
Normal file
0
swh/lister/pypi/tests/__init__.py
Normal file
1
swh/lister/pypi/tests/conftest.py
Normal file
1
swh/lister/pypi/tests/conftest.py
Normal file
|
@ -0,0 +1 @@
|
|||
from swh.lister.core.tests.conftest import * # noqa
|
27
swh/lister/pypi/tests/test_tasks.py
Normal file
27
swh/lister/pypi/tests/test_tasks.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
|
||||
def test_ping(swh_app, celery_session_worker):
|
||||
res = swh_app.send_task(
|
||||
'swh.lister.pypi.tasks.ping')
|
||||
assert res
|
||||
res.wait()
|
||||
assert res.successful()
|
||||
assert res.result == 'OK'
|
||||
|
||||
|
||||
@patch('swh.lister.pypi.tasks.PyPILister')
|
||||
def test_lister(lister, swh_app, celery_session_worker):
|
||||
# setup the mocked PypiLister
|
||||
lister.return_value = lister
|
||||
lister.run.return_value = None
|
||||
|
||||
res = swh_app.send_task(
|
||||
'swh.lister.pypi.tasks.PyPIListerTask')
|
||||
assert res
|
||||
res.wait()
|
||||
assert res.successful()
|
||||
|
||||
lister.assert_called_once_with()
|
||||
lister.db_last_index.assert_not_called()
|
||||
lister.run.assert_called_once_with()
|
Loading…
Add table
Add a link
Reference in a new issue