Skip to content

Commit 640ab99

Browse files
test for empty pd config
1 parent 336d255 commit 640ab99

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

core/pioreactor/background_jobs/od_reading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
from pioreactor import whoami
6363
from pioreactor.background_jobs.base import BackgroundJob
6464
from pioreactor.background_jobs.base import LoggerMixin
65-
from pioreactor.calibrations import load_active_calibration
6665
from pioreactor.config import config
6766
from pioreactor.pubsub import publish
6867
from pioreactor.states import JobState as st
@@ -1417,6 +1416,8 @@ def start_od_reading(
14171416
# use an OD calibration?
14181417
calibration_transformer: CalibrationTransformerProtocol
14191418
if calibration is True:
1419+
from pioreactor.calibrations import load_active_calibration
1420+
14201421
calibration_transformer = CachedCalibrationTransformer()
14211422
for channel, angle in channel_angle_map.items():
14221423
active_calibration = load_active_calibration(f"od{angle}") # type: ignore

core/tests/test_od_reading.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,29 @@ def test_can_pass_config_section_directly() -> None:
14531453
assert set(od.channel_angle_map.keys()) == {"1"}
14541454

14551455

1456+
def test_config_section_omits_empty_photodiode_channels() -> None:
1457+
experiment = "test_config_section_omits_empty_photodiode_channels"
1458+
with temporary_config_changes(
1459+
config,
1460+
[
1461+
("od_config.photodiode_channel", "1", "REF"),
1462+
("od_config.photodiode_channel", "2", "90"),
1463+
("od_config.photodiode_channel", "3", ""),
1464+
("od_config.photodiode_channel", "4", ""),
1465+
],
1466+
):
1467+
section = config["od_config.photodiode_channel"]
1468+
with start_od_reading(
1469+
section,
1470+
interval=None,
1471+
fake_data=True,
1472+
experiment=experiment,
1473+
calibration=False,
1474+
) as od:
1475+
assert set(od.channel_angle_map.keys()) == {"2"}
1476+
assert set(od.adc_reader.channels) == {"1", "2"}
1477+
1478+
14561479
def test_CachedCalibrationTransformer_with_real_calibration() -> None:
14571480
calibration = structs.OD600Calibration(
14581481
angle="90",

0 commit comments

Comments
 (0)