diff --git a/conftest.py b/conftest.py new file mode 100644 --- /dev/null +++ b/conftest.py @@ -0,0 +1,15 @@ +# 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 + +import pytest + +pytest_plugins = ["swh.scheduler.pytest_plugin", "swh.storage.pytest_plugin"] + + +@pytest.fixture(scope="session") +def swh_scheduler_celery_includes(swh_scheduler_celery_includes): + return swh_scheduler_celery_includes + [ + "swh.deposit.loader.tasks", + ] diff --git a/pytest.ini b/pytest.ini --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,6 @@ [pytest] -addopts = -p no:flask +# Remove the pytest_swh_* entries when they stop getting imported automatically +addopts = -p no:flask -p no:pytest_swh_scheduler -p no:pytest_swh_storage norecursedirs = docs DJANGO_SETTINGS_MODULE = swh.deposit.settings.testing diff --git a/swh/deposit/tests/conftest.py b/swh/deposit/tests/conftest.py --- a/swh/deposit/tests/conftest.py +++ b/swh/deposit/tests/conftest.py @@ -20,7 +20,6 @@ from typing import Mapping from swh.scheduler import get_scheduler -from swh.scheduler.tests.conftest import * # noqa from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT from swh.deposit.config import setup_django_for from swh.deposit.parsers import parse_xml diff --git a/swh/deposit/tests/loader/conftest.py b/swh/deposit/tests/loader/conftest.py --- a/swh/deposit/tests/loader/conftest.py +++ b/swh/deposit/tests/loader/conftest.py @@ -11,18 +11,9 @@ from functools import partial from swh.core.pytest_plugin import get_response_cb -from swh.scheduler.tests.conftest import * # noqa -from swh.storage.tests.conftest import * # noqa from swh.deposit.loader.checker import DepositChecker -@pytest.fixture(scope="session") # expected redefinition -def celery_includes(): - return [ - "swh.deposit.loader.tasks", - ] - - @pytest.fixture def swh_config(tmp_path, swh_storage_postgresql, monkeypatch): storage_config = { diff --git a/swh/deposit/tests/loader/test_tasks.py b/swh/deposit/tests/loader/test_tasks.py --- a/swh/deposit/tests/loader/test_tasks.py +++ b/swh/deposit/tests/loader/test_tasks.py @@ -7,7 +7,9 @@ @pytest.mark.db -def test_deposit_check_eventful(mocker, swh_config, swh_app, celery_session_worker): +def test_deposit_check_eventful( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): """Successful check should make the check succeed """ @@ -16,7 +18,7 @@ collection = "collection" deposit_id = 42 - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.deposit.loader.tasks.ChecksDepositTsk", args=[collection, deposit_id] ) assert res @@ -28,7 +30,9 @@ @pytest.mark.db -def test_deposit_check_failure(mocker, swh_config, swh_app, celery_session_worker): +def test_deposit_check_failure( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): """Unverified check status should make the check fail """ @@ -37,7 +41,7 @@ collection = "collec" deposit_id = 666 - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.deposit.loader.tasks.ChecksDepositTsk", args=[collection, deposit_id] ) assert res @@ -49,7 +53,9 @@ @pytest.mark.db -def test_deposit_check_3(mocker, swh_config, swh_app, celery_session_worker): +def test_deposit_check_3( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): """Unexpected failures should fail the check """ @@ -58,7 +64,7 @@ collection = "another-collection" deposit_id = 999 - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.deposit.loader.tasks.ChecksDepositTsk", args=[collection, deposit_id] ) assert res diff --git a/tox.ini b/tox.ini --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ # the dependency below is needed for now as a workaround for # https://github.com/pypa/pip/issues/6239 swh.core[http] >= 0.0.75 + swh.scheduler[testing] >= 0.5.0 dev: pdbpp pytest-cov django2: Django>=2,<3