From d08d4cd325f700c47d1b4366314877bbff861231 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Thu, 18 Dec 2025 17:08:02 +0000 Subject: [PATCH] Move unit tests to their own sub-dir in tests --- .gitignore | 5 ++--- pyproject.toml | 2 +- tests/{ => unit_tests}/__init__.py | 0 .../{ => unit_tests}/mock_stitching/mock-stitch.py | 0 tests/{ => unit_tests}/test_autofocus.py | 0 tests/{ => unit_tests}/test_background_detectors.py | 0 tests/{ => unit_tests}/test_camera.py | 0 tests/{ => unit_tests}/test_camera_buffer.py | 0 tests/{ => unit_tests}/test_cameras.py | 0 tests/{ => unit_tests}/test_config_utilities.py | 0 tests/{ => unit_tests}/test_dummy_server.py | 2 +- tests/{ => unit_tests}/test_legacy_api.py | 0 tests/{ => unit_tests}/test_lock_decorator.py | 0 tests/{ => unit_tests}/test_logging.py | 0 .../{ => unit_tests}/test_picamera_tuning_files.py | 0 tests/{ => unit_tests}/test_sangaboard.py | 0 tests/{ => unit_tests}/test_scan_data.py | 0 tests/{ => unit_tests}/test_scan_directories.py | 0 tests/{ => unit_tests}/test_scan_planners.py | 0 tests/{ => unit_tests}/test_serve_static_files.py | 0 tests/{ => unit_tests}/test_server_cli.py | 0 tests/{ => unit_tests}/test_server_config.py | 2 +- tests/{ => unit_tests}/test_smart_scan.py | 0 tests/{ => unit_tests}/test_stack.py | 0 tests/{ => unit_tests}/test_stage.py | 0 tests/{ => unit_tests}/test_stage_measure.py | 0 tests/{ => unit_tests}/test_stitching.py | 0 tests/{ => unit_tests}/test_system_thing.py | 0 tests/{ => unit_tests}/test_version_strings.py | 2 +- tests/{ => unit_tests}/utilities/__init__.py | 0 .../utilities/example_smart_spiral_core.pkl | Bin .../utilities/example_smart_spiral_lobed.pkl | Bin .../utilities/example_smart_spiral_regular.pkl | Bin tests/{ => unit_tests}/utilities/lt_test_utils.py | 0 .../{ => unit_tests}/utilities/scan_test_helpers.py | 0 35 files changed, 6 insertions(+), 7 deletions(-) rename tests/{ => unit_tests}/__init__.py (100%) rename tests/{ => unit_tests}/mock_stitching/mock-stitch.py (100%) rename tests/{ => unit_tests}/test_autofocus.py (100%) rename tests/{ => unit_tests}/test_background_detectors.py (100%) rename tests/{ => unit_tests}/test_camera.py (100%) rename tests/{ => unit_tests}/test_camera_buffer.py (100%) rename tests/{ => unit_tests}/test_cameras.py (100%) rename tests/{ => unit_tests}/test_config_utilities.py (100%) rename tests/{ => unit_tests}/test_dummy_server.py (98%) rename tests/{ => unit_tests}/test_legacy_api.py (100%) rename tests/{ => unit_tests}/test_lock_decorator.py (100%) rename tests/{ => unit_tests}/test_logging.py (100%) rename tests/{ => unit_tests}/test_picamera_tuning_files.py (100%) rename tests/{ => unit_tests}/test_sangaboard.py (100%) rename tests/{ => unit_tests}/test_scan_data.py (100%) rename tests/{ => unit_tests}/test_scan_directories.py (100%) rename tests/{ => unit_tests}/test_scan_planners.py (100%) rename tests/{ => unit_tests}/test_serve_static_files.py (100%) rename tests/{ => unit_tests}/test_server_cli.py (100%) rename tests/{ => unit_tests}/test_server_config.py (99%) rename tests/{ => unit_tests}/test_smart_scan.py (100%) rename tests/{ => unit_tests}/test_stack.py (100%) rename tests/{ => unit_tests}/test_stage.py (100%) rename tests/{ => unit_tests}/test_stage_measure.py (100%) rename tests/{ => unit_tests}/test_stitching.py (100%) rename tests/{ => unit_tests}/test_system_thing.py (100%) rename tests/{ => unit_tests}/test_version_strings.py (99%) rename tests/{ => unit_tests}/utilities/__init__.py (100%) rename tests/{ => unit_tests}/utilities/example_smart_spiral_core.pkl (100%) rename tests/{ => unit_tests}/utilities/example_smart_spiral_lobed.pkl (100%) rename tests/{ => unit_tests}/utilities/example_smart_spiral_regular.pkl (100%) rename tests/{ => unit_tests}/utilities/lt_test_utils.py (100%) rename tests/{ => unit_tests}/utilities/scan_test_helpers.py (100%) diff --git a/.gitignore b/.gitignore index acc08e3c..3054abce 100644 --- a/.gitignore +++ b/.gitignore @@ -69,7 +69,6 @@ target/ #Big-o files *.data -tests/images/out/ #IDE files .vscode/ @@ -89,8 +88,8 @@ openflexure_settings/ /src/openflexure_microscope_server/static/ # Files created by test utilities -/tests/utilities/*.pstats -/tests/utilities/*.png +/tests/unit_tests/utilities/*.pstats +/tests/unit_tests/utilities/*.png # Files created by simulator openflexure/ diff --git a/pyproject.toml b/pyproject.toml index b7728ed5..8f065ad5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ addopts = [ norecursedirs = [".git", "build", "node_modules"] pythonpath = ["."] -testpaths = ["tests"] +testpaths = ["tests/unit_tests"] [tool.ruff.format] # Use native line endings for all files diff --git a/tests/__init__.py b/tests/unit_tests/__init__.py similarity index 100% rename from tests/__init__.py rename to tests/unit_tests/__init__.py diff --git a/tests/mock_stitching/mock-stitch.py b/tests/unit_tests/mock_stitching/mock-stitch.py similarity index 100% rename from tests/mock_stitching/mock-stitch.py rename to tests/unit_tests/mock_stitching/mock-stitch.py diff --git a/tests/test_autofocus.py b/tests/unit_tests/test_autofocus.py similarity index 100% rename from tests/test_autofocus.py rename to tests/unit_tests/test_autofocus.py diff --git a/tests/test_background_detectors.py b/tests/unit_tests/test_background_detectors.py similarity index 100% rename from tests/test_background_detectors.py rename to tests/unit_tests/test_background_detectors.py diff --git a/tests/test_camera.py b/tests/unit_tests/test_camera.py similarity index 100% rename from tests/test_camera.py rename to tests/unit_tests/test_camera.py diff --git a/tests/test_camera_buffer.py b/tests/unit_tests/test_camera_buffer.py similarity index 100% rename from tests/test_camera_buffer.py rename to tests/unit_tests/test_camera_buffer.py diff --git a/tests/test_cameras.py b/tests/unit_tests/test_cameras.py similarity index 100% rename from tests/test_cameras.py rename to tests/unit_tests/test_cameras.py diff --git a/tests/test_config_utilities.py b/tests/unit_tests/test_config_utilities.py similarity index 100% rename from tests/test_config_utilities.py rename to tests/unit_tests/test_config_utilities.py diff --git a/tests/test_dummy_server.py b/tests/unit_tests/test_dummy_server.py similarity index 98% rename from tests/test_dummy_server.py rename to tests/unit_tests/test_dummy_server.py index e26e3d62..217bc9d2 100644 --- a/tests/test_dummy_server.py +++ b/tests/unit_tests/test_dummy_server.py @@ -44,7 +44,7 @@ def test_env(): def test_autofocus(test_env): """Test Fast Autofocus can run doesn't raise an exception.""" # Adjust the time for stage is 100 microseconds rather than 1 microsecond. - test_env.get_thing_by_name["stage"].step_time = 0.0001 + test_env.get_thing_by_name("stage").step_time = 0.0001 autofocus = test_env.get_thing_client("autofocus") _ = autofocus.fast_autofocus() diff --git a/tests/test_legacy_api.py b/tests/unit_tests/test_legacy_api.py similarity index 100% rename from tests/test_legacy_api.py rename to tests/unit_tests/test_legacy_api.py diff --git a/tests/test_lock_decorator.py b/tests/unit_tests/test_lock_decorator.py similarity index 100% rename from tests/test_lock_decorator.py rename to tests/unit_tests/test_lock_decorator.py diff --git a/tests/test_logging.py b/tests/unit_tests/test_logging.py similarity index 100% rename from tests/test_logging.py rename to tests/unit_tests/test_logging.py diff --git a/tests/test_picamera_tuning_files.py b/tests/unit_tests/test_picamera_tuning_files.py similarity index 100% rename from tests/test_picamera_tuning_files.py rename to tests/unit_tests/test_picamera_tuning_files.py diff --git a/tests/test_sangaboard.py b/tests/unit_tests/test_sangaboard.py similarity index 100% rename from tests/test_sangaboard.py rename to tests/unit_tests/test_sangaboard.py diff --git a/tests/test_scan_data.py b/tests/unit_tests/test_scan_data.py similarity index 100% rename from tests/test_scan_data.py rename to tests/unit_tests/test_scan_data.py diff --git a/tests/test_scan_directories.py b/tests/unit_tests/test_scan_directories.py similarity index 100% rename from tests/test_scan_directories.py rename to tests/unit_tests/test_scan_directories.py diff --git a/tests/test_scan_planners.py b/tests/unit_tests/test_scan_planners.py similarity index 100% rename from tests/test_scan_planners.py rename to tests/unit_tests/test_scan_planners.py diff --git a/tests/test_serve_static_files.py b/tests/unit_tests/test_serve_static_files.py similarity index 100% rename from tests/test_serve_static_files.py rename to tests/unit_tests/test_serve_static_files.py diff --git a/tests/test_server_cli.py b/tests/unit_tests/test_server_cli.py similarity index 100% rename from tests/test_server_cli.py rename to tests/unit_tests/test_server_cli.py diff --git a/tests/test_server_config.py b/tests/unit_tests/test_server_config.py similarity index 99% rename from tests/test_server_config.py rename to tests/unit_tests/test_server_config.py index 82b22929..d7ee4e86 100644 --- a/tests/test_server_config.py +++ b/tests/unit_tests/test_server_config.py @@ -11,7 +11,7 @@ import pytest from openflexure_microscope_server import server as ofm_server THIS_DIR = os.path.dirname(os.path.abspath(__file__)) -REPO_ROOT = os.path.dirname(THIS_DIR) +REPO_ROOT = os.path.dirname(os.path.dirname(THIS_DIR)) FULL_CONFIG = os.path.join(REPO_ROOT, "ofm_config_full.json") SIM_CONFIG = os.path.join(REPO_ROOT, "ofm_config_simulation.json") diff --git a/tests/test_smart_scan.py b/tests/unit_tests/test_smart_scan.py similarity index 100% rename from tests/test_smart_scan.py rename to tests/unit_tests/test_smart_scan.py diff --git a/tests/test_stack.py b/tests/unit_tests/test_stack.py similarity index 100% rename from tests/test_stack.py rename to tests/unit_tests/test_stack.py diff --git a/tests/test_stage.py b/tests/unit_tests/test_stage.py similarity index 100% rename from tests/test_stage.py rename to tests/unit_tests/test_stage.py diff --git a/tests/test_stage_measure.py b/tests/unit_tests/test_stage_measure.py similarity index 100% rename from tests/test_stage_measure.py rename to tests/unit_tests/test_stage_measure.py diff --git a/tests/test_stitching.py b/tests/unit_tests/test_stitching.py similarity index 100% rename from tests/test_stitching.py rename to tests/unit_tests/test_stitching.py diff --git a/tests/test_system_thing.py b/tests/unit_tests/test_system_thing.py similarity index 100% rename from tests/test_system_thing.py rename to tests/unit_tests/test_system_thing.py diff --git a/tests/test_version_strings.py b/tests/unit_tests/test_version_strings.py similarity index 99% rename from tests/test_version_strings.py rename to tests/unit_tests/test_version_strings.py index 3fa6a8fd..fc8fd817 100644 --- a/tests/test_version_strings.py +++ b/tests/unit_tests/test_version_strings.py @@ -16,7 +16,7 @@ from openflexure_microscope_server import utilities # Useful for really finding the repo dir when we mock where it is. THIS_DIR = os.path.dirname(__file__) -TRUE_REPO_DIR = os.path.dirname(THIS_DIR) +TRUE_REPO_DIR = os.path.dirname(os.path.dirname(THIS_DIR)) # For explicit version checking. VER_STRING = "3.0.0-alpha4" diff --git a/tests/utilities/__init__.py b/tests/unit_tests/utilities/__init__.py similarity index 100% rename from tests/utilities/__init__.py rename to tests/unit_tests/utilities/__init__.py diff --git a/tests/utilities/example_smart_spiral_core.pkl b/tests/unit_tests/utilities/example_smart_spiral_core.pkl similarity index 100% rename from tests/utilities/example_smart_spiral_core.pkl rename to tests/unit_tests/utilities/example_smart_spiral_core.pkl diff --git a/tests/utilities/example_smart_spiral_lobed.pkl b/tests/unit_tests/utilities/example_smart_spiral_lobed.pkl similarity index 100% rename from tests/utilities/example_smart_spiral_lobed.pkl rename to tests/unit_tests/utilities/example_smart_spiral_lobed.pkl diff --git a/tests/utilities/example_smart_spiral_regular.pkl b/tests/unit_tests/utilities/example_smart_spiral_regular.pkl similarity index 100% rename from tests/utilities/example_smart_spiral_regular.pkl rename to tests/unit_tests/utilities/example_smart_spiral_regular.pkl diff --git a/tests/utilities/lt_test_utils.py b/tests/unit_tests/utilities/lt_test_utils.py similarity index 100% rename from tests/utilities/lt_test_utils.py rename to tests/unit_tests/utilities/lt_test_utils.py diff --git a/tests/utilities/scan_test_helpers.py b/tests/unit_tests/utilities/scan_test_helpers.py similarity index 100% rename from tests/utilities/scan_test_helpers.py rename to tests/unit_tests/utilities/scan_test_helpers.py