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.loader.git.tasks", + ] diff --git a/pytest.ini b/pytest.ini --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,5 @@ [pytest] +# Drop this when these fixtures aren't imported automatically +addopts = -p no:pytest_swh_scheduler -p no:pytest_swh_storage + norecursedirs = docs diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,4 @@ pytest pytest-mock -swh.scheduler[testing] +swh.scheduler[testing] >= 0.5.0 swh.storage[testing] diff --git a/swh/loader/git/tests/conftest.py b/swh/loader/git/tests/conftest.py --- a/swh/loader/git/tests/conftest.py +++ b/swh/loader/git/tests/conftest.py @@ -10,9 +10,6 @@ from typing import Any, Dict -from swh.scheduler.tests.conftest import * # noqa -from swh.storage.tests.conftest import * # noqa - @pytest.fixture def swh_loader_config(swh_storage_backend_config) -> Dict[str, Any]: @@ -48,10 +45,3 @@ f.write(yaml.dump(swh_loader_config)) monkeypatch.setenv("SWH_CONFIG_FILENAME", conffile) return conffile - - -@pytest.fixture(scope="session") # type: ignore # expected redefinition -def celery_includes(): - return [ - "swh.loader.git.tasks", - ] diff --git a/swh/loader/git/tests/test_tasks.py b/swh/loader/git/tests/test_tasks.py --- a/swh/loader/git/tests/test_tasks.py +++ b/swh/loader/git/tests/test_tasks.py @@ -4,11 +4,11 @@ # See top-level LICENSE file for more information -def test_git_loader(mocker, swh_app, celery_session_worker): +def test_git_loader(mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker): mock_loader = mocker.patch("swh.loader.git.loader.GitLoader.load") mock_loader.return_value = {"status": "eventful"} - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.loader.git.tasks.UpdateGitRepository", kwargs={"url": "origin_url",} ) assert res @@ -19,11 +19,13 @@ mock_loader.assert_called_once_with() -def test_git_loader_from_disk(mocker, swh_app, celery_session_worker): +def test_git_loader_from_disk( + mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker +): mock_loader = mocker.patch("swh.loader.git.from_disk.GitLoaderFromDisk.load") mock_loader.return_value = {"status": "uneventful"} - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.loader.git.tasks.LoadDiskGitRepository", kwargs={ "url": "origin_url2", @@ -39,12 +41,14 @@ mock_loader.assert_called_once_with() -def test_git_loader_from_archive(mocker, swh_app, celery_session_worker): +def test_git_loader_from_archive( + mocker, swh_scheduler_celery_app, swh_scheduler_celery_worker +): mock_loader = mocker.patch("swh.loader.git.from_disk.GitLoaderFromArchive.load") mock_loader.return_value = {"status": "failed"} - res = swh_app.send_task( + res = swh_scheduler_celery_app.send_task( "swh.loader.git.tasks.UncompressAndLoadDiskGitRepository", kwargs={ "url": "origin_url3", diff --git a/tox.ini b/tox.ini --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ # TODO: remove when this issue is fixed swh.core[http] >= 0.0.61 swh.storage[testing] + swh.scheduler[testing] >= 0.5.0 pytest-cov commands = pytest --cov={envsitepackagesdir}/swh/loader/git \