Add tests for debian tasks
This commit is contained in:
parent
f375df5892
commit
33ec762bd4
4 changed files with 31 additions and 0 deletions
|
@ -10,6 +10,7 @@ def celery_enable_logging():
|
|||
def celery_includes():
|
||||
return [
|
||||
'swh.lister.bitbucket.tasks',
|
||||
'swh.lister.debian.tasks',
|
||||
'swh.lister.github.tasks',
|
||||
]
|
||||
|
||||
|
|
0
swh/lister/debian/tests/__init__.py
Normal file
0
swh/lister/debian/tests/__init__.py
Normal file
1
swh/lister/debian/tests/conftest.py
Normal file
1
swh/lister/debian/tests/conftest.py
Normal file
|
@ -0,0 +1 @@
|
|||
from swh.lister.core.tests.conftest import * # noqa
|
29
swh/lister/debian/tests/test_tasks.py
Normal file
29
swh/lister/debian/tests/test_tasks.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from time import sleep
|
||||
from celery.result import GroupResult
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def test_ping(swh_app, celery_session_worker):
|
||||
res = swh_app.send_task(
|
||||
'swh.lister.debian.tasks.ping')
|
||||
assert res
|
||||
res.wait()
|
||||
assert res.successful()
|
||||
assert res.result == 'OK'
|
||||
|
||||
|
||||
@patch('swh.lister.debian.tasks.DebianLister')
|
||||
def test_lister(lister, swh_app, celery_session_worker):
|
||||
# setup the mocked DebianLister
|
||||
lister.return_value = lister
|
||||
lister.run.return_value = None
|
||||
|
||||
res = swh_app.send_task(
|
||||
'swh.lister.debian.tasks.DebianListerTask', ('stretch',))
|
||||
assert res
|
||||
res.wait()
|
||||
assert res.successful()
|
||||
|
||||
lister.assert_called_once_with()
|
||||
lister.run.assert_called_once_with('stretch')
|
Loading…
Add table
Add a link
Reference in a new issue