From 49fd0a54a4f7ba80bed933cf8f90c800e047186c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Malinowski?= <56644812+stan-dot@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:06:41 +0100 Subject: [PATCH] Move system tests to a separate directory (#822) * tests moved * fix the lint settings to take the new dir into account * docs snippet --- docs/how-to/write-tests.md | 8 ++++++++ pyproject.toml | 3 ++- {tests/devices/system_tests => system_tests}/__init__.py | 0 .../test_aperturescatterguard_system.py | 0 .../system_tests => system_tests}/test_eiger_system.py | 0 .../system_tests => system_tests}/test_gridscan_system.py | 0 .../system_tests => system_tests}/test_oav_system.py | 0 .../test_oav_to_redis_system.py | 0 .../test_slit_gaps_system.py | 0 .../system_tests => system_tests}/test_smargon_system.py | 0 .../test_synchrotron_system.py | 0 .../test_undulator_system.py | 0 .../system_tests => system_tests}/test_zebra_system.py | 0 .../system_tests => system_tests}/test_zocalo_results.py | 0 14 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 docs/how-to/write-tests.md rename {tests/devices/system_tests => system_tests}/__init__.py (100%) rename {tests/devices/system_tests => system_tests}/test_aperturescatterguard_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_eiger_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_gridscan_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_oav_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_oav_to_redis_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_slit_gaps_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_smargon_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_synchrotron_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_undulator_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_zebra_system.py (100%) rename {tests/devices/system_tests => system_tests}/test_zocalo_results.py (100%) diff --git a/docs/how-to/write-tests.md b/docs/how-to/write-tests.md new file mode 100644 index 0000000000..ad4316e4fe --- /dev/null +++ b/docs/how-to/write-tests.md @@ -0,0 +1,8 @@ +# Writing Tests in This Python Project + +Testing is essential to maintain the integrity and reliability of the codebase. Follow the guidelines below to write tests for this project effectively. + +## Test Organization + +- **Unit Tests**: Place unit tests for individual components in the `tests` directory, but take care to mirror the file structure of the `src` folder with the corresponding code files. Use the `test_*.py` naming convention for test files. +- **System Tests**: Tests that interact with DLS infrastructure, network, and filesystem should be placed in the top-level `systems_test` folder. This separation ensures that these tests are easily identifiable and can be run independently from unit tests. diff --git a/pyproject.toml b/pyproject.toml index f1f8e42e63..b65b66a9a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,7 +115,7 @@ filterwarnings = [ "ignore::DeprecationWarning:wheel", ] # Doctest python code in docs, python code in src docstrings, test functions in tests -testpaths = "docs src tests" +testpaths = "docs src tests system_tests" [tool.coverage.report] exclude_also = [ @@ -176,3 +176,4 @@ lint.select = [ # See https://github.com/DiamondLightSource/python-copier-template/issues/154 # Remove this line to forbid private member access in tests "tests/**/*" = ["SLF001"] +"system_tests/**/*" = ["SLF001"] diff --git a/tests/devices/system_tests/__init__.py b/system_tests/__init__.py similarity index 100% rename from tests/devices/system_tests/__init__.py rename to system_tests/__init__.py diff --git a/tests/devices/system_tests/test_aperturescatterguard_system.py b/system_tests/test_aperturescatterguard_system.py similarity index 100% rename from tests/devices/system_tests/test_aperturescatterguard_system.py rename to system_tests/test_aperturescatterguard_system.py diff --git a/tests/devices/system_tests/test_eiger_system.py b/system_tests/test_eiger_system.py similarity index 100% rename from tests/devices/system_tests/test_eiger_system.py rename to system_tests/test_eiger_system.py diff --git a/tests/devices/system_tests/test_gridscan_system.py b/system_tests/test_gridscan_system.py similarity index 100% rename from tests/devices/system_tests/test_gridscan_system.py rename to system_tests/test_gridscan_system.py diff --git a/tests/devices/system_tests/test_oav_system.py b/system_tests/test_oav_system.py similarity index 100% rename from tests/devices/system_tests/test_oav_system.py rename to system_tests/test_oav_system.py diff --git a/tests/devices/system_tests/test_oav_to_redis_system.py b/system_tests/test_oav_to_redis_system.py similarity index 100% rename from tests/devices/system_tests/test_oav_to_redis_system.py rename to system_tests/test_oav_to_redis_system.py diff --git a/tests/devices/system_tests/test_slit_gaps_system.py b/system_tests/test_slit_gaps_system.py similarity index 100% rename from tests/devices/system_tests/test_slit_gaps_system.py rename to system_tests/test_slit_gaps_system.py diff --git a/tests/devices/system_tests/test_smargon_system.py b/system_tests/test_smargon_system.py similarity index 100% rename from tests/devices/system_tests/test_smargon_system.py rename to system_tests/test_smargon_system.py diff --git a/tests/devices/system_tests/test_synchrotron_system.py b/system_tests/test_synchrotron_system.py similarity index 100% rename from tests/devices/system_tests/test_synchrotron_system.py rename to system_tests/test_synchrotron_system.py diff --git a/tests/devices/system_tests/test_undulator_system.py b/system_tests/test_undulator_system.py similarity index 100% rename from tests/devices/system_tests/test_undulator_system.py rename to system_tests/test_undulator_system.py diff --git a/tests/devices/system_tests/test_zebra_system.py b/system_tests/test_zebra_system.py similarity index 100% rename from tests/devices/system_tests/test_zebra_system.py rename to system_tests/test_zebra_system.py diff --git a/tests/devices/system_tests/test_zocalo_results.py b/system_tests/test_zocalo_results.py similarity index 100% rename from tests/devices/system_tests/test_zocalo_results.py rename to system_tests/test_zocalo_results.py