From 7cbcadd5f4f12780f06c12890016ee9035b479a7 Mon Sep 17 00:00:00 2001 From: David Perl Date: Fri, 5 Apr 2024 09:01:46 +0100 Subject: [PATCH] (#391) fix logging and LUT tests --- .../unit_tests/util/test_adjuster_plans.py | 2 +- tests/plans/test_topup_plan.py | 2 +- tests/unit_tests/test_log.py | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/devices/unit_tests/util/test_adjuster_plans.py b/tests/devices/unit_tests/util/test_adjuster_plans.py index 3c1802aa18..72dd11c9f9 100644 --- a/tests/devices/unit_tests/util/test_adjuster_plans.py +++ b/tests/devices/unit_tests/util/test_adjuster_plans.py @@ -10,7 +10,7 @@ @pytest.fixture def fake_aperture(): FakeAperture = make_fake_device(Aperture) - fake_aperture: Aperture = FakeAperture(name="aperture") + fake_aperture: Aperture = FakeAperture(prefix="", name="aperture") return fake_aperture diff --git a/tests/plans/test_topup_plan.py b/tests/plans/test_topup_plan.py index 4cb079af1c..bcc73cc03d 100644 --- a/tests/plans/test_topup_plan.py +++ b/tests/plans/test_topup_plan.py @@ -14,7 +14,7 @@ @pytest.fixture -def synchrotron() -> Synchrotron: +def synchrotron(RE) -> Synchrotron: return i03.synchrotron(fake_with_ophyd_sim=True) diff --git a/tests/unit_tests/test_log.py b/tests/unit_tests/test_log.py index d0ed3205f6..deca8ab19c 100644 --- a/tests/unit_tests/test_log.py +++ b/tests/unit_tests/test_log.py @@ -4,6 +4,7 @@ import pytest from graypy import GELFTCPHandler +from ophyd import log as ophyd_log from dodal import log from dodal.log import ( @@ -130,6 +131,10 @@ def test_various_messages_to_graylog_get_beamline_filter( ): from os import environ + from bluesky.run_engine import RunEngine + + RE = RunEngine() + if environ.get("BEAMLINE"): del environ["BEAMLINE"] log.beamline_filter = log.BeamlineFilter() @@ -157,19 +162,11 @@ def mock_set_up_graylog_handler(logger, host, port): mock_GELFTCPHandler.emit.assert_called() assert mock_GELFTCPHandler.emit.call_args.args[0].beamline == "dev" - from dodal.beamlines import i03 - - _aperture_scatterguard = i03.aperture_scatterguard( - fake_with_ophyd_sim=True, wait_for_connection=True - ) + ophyd_log.logger.info("Ophyd log message") assert mock_GELFTCPHandler.emit.call_args.args[0].name == "ophyd" assert mock_GELFTCPHandler.emit.call_args.args[0].beamline == "dev" - from bluesky.run_engine import RunEngine - - RE = RunEngine() RE.log.logger.info("RunEngine log message") - assert mock_GELFTCPHandler.emit.call_args.args[0].name == "bluesky" assert mock_GELFTCPHandler.emit.call_args.args[0].beamline == "dev"