diff --git a/swh/lister/core/tests/conftest.py b/swh/lister/core/tests/conftest.py index 5d75455..89e28a6 100644 --- a/swh/lister/core/tests/conftest.py +++ b/swh/lister/core/tests/conftest.py @@ -14,6 +14,7 @@ def celery_includes(): 'swh.lister.github.tasks', 'swh.lister.gitlab.tasks', 'swh.lister.npm.tasks', + 'swh.lister.pypi.tasks', ] diff --git a/swh/lister/pypi/tests/__init__.py b/swh/lister/pypi/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/swh/lister/pypi/tests/conftest.py b/swh/lister/pypi/tests/conftest.py new file mode 100644 index 0000000..507fef9 --- /dev/null +++ b/swh/lister/pypi/tests/conftest.py @@ -0,0 +1 @@ +from swh.lister.core.tests.conftest import * # noqa diff --git a/swh/lister/pypi/tests/test_tasks.py b/swh/lister/pypi/tests/test_tasks.py new file mode 100644 index 0000000..ab7032b --- /dev/null +++ b/swh/lister/pypi/tests/test_tasks.py @@ -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()