Skip to content

Commit 19b71d9

Browse files
config for test
1 parent 8232c6f commit 19b71d9

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

core/tests/test_od_fusion_offset_protocol.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pioreactor import structs
1010
from pioreactor.calibrations.protocols import od_fusion_offset
1111
from pioreactor.config import config
12+
from pioreactor.config import temporary_config_change
1213

1314

1415
def _example_akima() -> structs.AkimaFitData:
@@ -55,37 +56,38 @@ def test_affine_transform_cubic_fit_data_rejects_non_positive_scale() -> None:
5556

5657

5758
def test_apply_logc_affine_to_estimator_applies_transform() -> None:
58-
estimator = _example_estimator()
59-
60-
updated = od_fusion_offset._apply_logc_affine_to_estimator(
61-
estimator,
62-
estimator_name="updated",
63-
calibrated_on_unit="unit2",
64-
scale_logc=2.0,
65-
offset_logc=1.0,
66-
standards=[{"od": 0.3}],
67-
source_unit="unit1",
68-
source_estimator_name="base-estimator",
69-
)
7059

71-
assert updated.estimator_name == "updated"
72-
assert updated.calibrated_on_pioreactor_unit == "unit2"
73-
assert updated.min_logc == pytest.approx(1.2)
74-
assert updated.max_logc == pytest.approx(3.4)
75-
assert updated.angles == ["45"]
76-
assert updated.mu_splines["45"].knots == [1.0, 3.0]
77-
assert updated.sigma_splines_log["45"].knots == [1.0, 3.0]
78-
79-
recorded_data = updated.recorded_data
80-
assert recorded_data["base_recorded_data"] == {"base": "data"}
81-
assert recorded_data["standards"] == [{"od": 0.3}]
82-
83-
transform: dict[str, Any] = recorded_data["transform"]
84-
assert transform["type"] == "logc_affine"
85-
assert transform["scale_logc"] == 2.0
86-
assert transform["offset_logc"] == 1.0
87-
assert transform["source_unit"] == "unit1"
88-
assert transform["source_estimator_name"] == "base-estimator"
89-
assert transform["source_ir_led_intensity"] == 10.0
90-
91-
assert updated.ir_led_intensity == config.getfloat("od_reading.config", "ir_led_intensity")
60+
with temporary_config_change(config, "od_reading.config", "ir_led_intensity", "70"):
61+
62+
estimator = _example_estimator()
63+
64+
updated = od_fusion_offset._apply_logc_affine_to_estimator(
65+
estimator,
66+
estimator_name="updated",
67+
calibrated_on_unit="unit2",
68+
scale_logc=2.0,
69+
offset_logc=1.0,
70+
standards=[{"od": 0.3}],
71+
source_unit="unit1",
72+
source_estimator_name="base-estimator",
73+
)
74+
75+
assert updated.estimator_name == "updated"
76+
assert updated.calibrated_on_pioreactor_unit == "unit2"
77+
assert updated.min_logc == pytest.approx(1.2)
78+
assert updated.max_logc == pytest.approx(3.4)
79+
assert updated.angles == ["45"]
80+
assert updated.mu_splines["45"].knots == [1.0, 3.0]
81+
assert updated.sigma_splines_log["45"].knots == [1.0, 3.0]
82+
83+
recorded_data = updated.recorded_data
84+
assert recorded_data["base_recorded_data"] == {"base": "data"}
85+
assert recorded_data["standards"] == [{"od": 0.3}]
86+
87+
transform: dict[str, Any] = recorded_data["transform"]
88+
assert transform["type"] == "logc_affine"
89+
assert transform["scale_logc"] == 2.0
90+
assert transform["offset_logc"] == 1.0
91+
assert transform["source_unit"] == "unit1"
92+
assert transform["source_estimator_name"] == "base-estimator"
93+
assert transform["source_ir_led_intensity"] == 10.0

0 commit comments

Comments
 (0)