diff --git a/requirements/testing.txt b/requirements/testing.txt index e5eb45f79..40bff2af0 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -1,6 +1,6 @@ pytest pytest-cov -pytest-docker-compose +pytest-docker pytest-dependency pytest-order so3g diff --git a/tests/integration/test_cryomech_cpa_agent_integration.py b/tests/integration/test_cryomech_cpa_agent_integration.py index 84844d164..ea4f32322 100644 --- a/tests/integration/test_cryomech_cpa_agent_integration.py +++ b/tests/integration/test_cryomech_cpa_agent_integration.py @@ -2,14 +2,13 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - # Set the OCS_CONFIG_DIR so we read the local default.yaml file always os.environ['OCS_CONFIG_DIR'] = os.getcwd() diff --git a/tests/integration/test_hwp_pid_agent_integration.py b/tests/integration/test_hwp_pid_agent_integration.py index 7e6b57e32..48a0107b2 100644 --- a/tests/integration/test_hwp_pid_agent_integration.py +++ b/tests/integration/test_hwp_pid_agent_integration.py @@ -1,13 +1,12 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( '../socs/agents/hwp_pid/agent.py', 'hwp_pid_agent', args=['--log-dir', './logs/']) diff --git a/tests/integration/test_hwp_pmx_agent_integration.py b/tests/integration/test_hwp_pmx_agent_integration.py index 6864d85be..4e7dffeb7 100644 --- a/tests/integration/test_hwp_pmx_agent_integration.py +++ b/tests/integration/test_hwp_pmx_agent_integration.py @@ -1,13 +1,12 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( '../socs/agents/hwp_pmx/agent.py', 'hwp_pmx_agent', args=['--log-dir', './logs/']) diff --git a/tests/integration/test_ibootbar_agent_integration.py b/tests/integration/test_ibootbar_agent_integration.py index 32b378c57..17d044f24 100644 --- a/tests/integration/test_ibootbar_agent_integration.py +++ b/tests/integration/test_ibootbar_agent_integration.py @@ -6,6 +6,7 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture @@ -14,8 +15,6 @@ from socs.snmp import SNMPTwister -pytest_plugins = "docker_compose" - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( "../socs/agents/ibootbar/agent.py", diff --git a/tests/integration/test_ls240_agent_integration.py b/tests/integration/test_ls240_agent_integration.py index 7df4ab024..ac8c27066 100644 --- a/tests/integration/test_ls240_agent_integration.py +++ b/tests/integration/test_ls240_agent_integration.py @@ -2,14 +2,13 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( '../socs/agents/lakeshore240/agent.py', 'ls240_agent') diff --git a/tests/integration/test_ls372_agent_integration.py b/tests/integration/test_ls372_agent_integration.py index 383f45251..a60df034f 100644 --- a/tests/integration/test_ls372_agent_integration.py +++ b/tests/integration/test_ls372_agent_integration.py @@ -2,14 +2,13 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - # Set the OCS_CONFIG_DIR so we read the local default.yaml file always os.environ['OCS_CONFIG_DIR'] = os.getcwd() diff --git a/tests/integration/test_ls425_agent_integration.py b/tests/integration/test_ls425_agent_integration.py index bcfb032fa..237f05e4e 100644 --- a/tests/integration/test_ls425_agent_integration.py +++ b/tests/integration/test_ls425_agent_integration.py @@ -2,14 +2,13 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( '../socs/agents/lakeshore425/agent.py', 'ls425_agent') diff --git a/tests/integration/test_pfeiffer_tc400_agent_integration.py b/tests/integration/test_pfeiffer_tc400_agent_integration.py index 34178f479..51ac78146 100644 --- a/tests/integration/test_pfeiffer_tc400_agent_integration.py +++ b/tests/integration/test_pfeiffer_tc400_agent_integration.py @@ -2,14 +2,13 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = ("docker_compose") - # Set the OCS_CONFIG_DIR so we read the local default.yaml file always os.environ['OCS_CONFIG_DIR'] = os.getcwd() diff --git a/tests/integration/test_pfeiffer_tpg366_agent_integration.py b/tests/integration/test_pfeiffer_tpg366_agent_integration.py index 01a1223ef..9d40ebe94 100644 --- a/tests/integration/test_pfeiffer_tpg366_agent_integration.py +++ b/tests/integration/test_pfeiffer_tpg366_agent_integration.py @@ -1,13 +1,12 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = "docker_compose" - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( "../socs/agents/pfeiffer_tpg366/agent.py", diff --git a/tests/integration/test_pysmurf_monitor_integration.py b/tests/integration/test_pysmurf_monitor_integration.py index 288deb977..f08b98c82 100644 --- a/tests/integration/test_pysmurf_monitor_integration.py +++ b/tests/integration/test_pysmurf_monitor_integration.py @@ -6,12 +6,11 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture -pytest_plugins = "docker_compose" - TMPFILE = '/tmp/pytest-socs/suprsync.db' wait_for_crossbar = create_crossbar_fixture() diff --git a/tests/integration/test_scpi_psu_agent_integration.py b/tests/integration/test_scpi_psu_agent_integration.py index a7f75bb67..318881b3d 100644 --- a/tests/integration/test_scpi_psu_agent_integration.py +++ b/tests/integration/test_scpi_psu_agent_integration.py @@ -1,13 +1,12 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from socs.testing.device_emulator import create_device_emulator -pytest_plugins = "docker_compose" - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( "../socs/agents/scpi_psu/agent.py", diff --git a/tests/integration/test_synacc_integration.py b/tests/integration/test_synacc_integration.py index 483b1053f..f04022b2d 100644 --- a/tests/integration/test_synacc_integration.py +++ b/tests/integration/test_synacc_integration.py @@ -2,12 +2,11 @@ import pytest from flask import request from http_server_mock import HttpServerMock +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture -pytest_plugins = "docker_compose" - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( "../socs/agents/synacc/agent.py", diff --git a/tests/integration/test_ups_agent_integration.py b/tests/integration/test_ups_agent_integration.py index b389f34e4..9ab381e0d 100644 --- a/tests/integration/test_ups_agent_integration.py +++ b/tests/integration/test_ups_agent_integration.py @@ -6,13 +6,12 @@ import ocs import pytest +from integration.util import docker_compose_file # noqa: F401 from integration.util import create_crossbar_fixture from ocs.base import OpCode from ocs.testing import create_agent_runner_fixture, create_client_fixture from snmpsim.commands import responder -pytest_plugins = "docker_compose" - wait_for_crossbar = create_crossbar_fixture() run_agent = create_agent_runner_fixture( "../socs/agents/ups/agent.py", diff --git a/tests/integration/util.py b/tests/integration/util.py index 8f2298c36..b5f13f486 100644 --- a/tests/integration/util.py +++ b/tests/integration/util.py @@ -1,3 +1,5 @@ +import os + import pytest from ocs.testing import check_crossbar_connection @@ -11,7 +13,7 @@ def create_crossbar_fixture(): # @pytest.fixture(scope="function") # def wait_for_crossbar(function_scoped_container_getter): @pytest.fixture(scope="session") - def wait_for_crossbar(session_scoped_container_getter): + def wait_for_crossbar(docker_services): """Wait for the crossbar server from docker-compose to become responsive. @@ -19,3 +21,10 @@ def wait_for_crossbar(session_scoped_container_getter): check_crossbar_connection() return wait_for_crossbar + + +# Overrides the default location that pytest-docker looks for the compose file. +# https://pypi.org/project/pytest-docker/ +@pytest.fixture(scope="session") +def docker_compose_file(pytestconfig): + return os.path.join(str(pytestconfig.rootdir), "docker-compose.yml")