Skip to content

Commit d3cef8a

Browse files
fix some tests
1 parent b575273 commit d3cef8a

File tree

5 files changed

+45
-22
lines changed

5 files changed

+45
-22
lines changed

core/pioreactor/background_jobs/od_reading.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,20 +732,25 @@ def _calibrate_signal(observed_voltage: pt.Voltage) -> pt.OD:
732732

733733
def __call__(self, od_readings: structs.ODReadings) -> structs.CalibratedODReadings:
734734
od_readings = copy(od_readings)
735+
calibrated_od_readings = structs.CalibratedODReadings(ods={}, timestamp=od_readings.timestamp)
736+
735737
for channel in self.models:
736738
if channel in od_readings.ods:
737739
raw_od = od_readings.ods[channel]
738740

739-
# check if everything is okay
741+
# check if everything is okay - blows up if not.
740742
self.verifiers[channel](raw_od)
741743

742-
od_readings.ods[channel] = structs.CalibratedODReading(
743-
**raw_od,
744+
calibrated_od_readings.ods[channel] = structs.CalibratedODReading(
744745
od=self.models[channel](raw_od.od),
745746
calibration_name=self.models[channel].name, # type: ignore
747+
channel=raw_od.channel,
748+
angle=raw_od.angle,
749+
timestamp=raw_od.timestamp,
750+
ir_led_intensity=raw_od.ir_led_intensity,
746751
)
747-
assert isinstance(od_readings, structs.CalibratedODReadings)
748-
return od_readings
752+
assert isinstance(calibrated_od_readings, structs.CalibratedODReadings)
753+
return calibrated_od_readings
749754

750755

751756
class ODReader(BackgroundJob):

core/tests/test_dosing_automation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def test_throughput_calculator_manual_set() -> None:
672672
def test_execute_io_action() -> None:
673673
experiment = "test_execute_io_action"
674674

675-
with Silent(unit=unit, experiment=experiment, volume_ml=15.0, max_working_volume_ml=15.0) as ca:
675+
with Silent(unit=unit, experiment=experiment, current_volume_ml=15.0, max_working_volume_ml=15.0) as ca:
676676
ca.execute_io_action(media_ml=0.50, alt_media_ml=0.35, waste_ml=0.50 + 0.35)
677677
pause()
678678
assert ca.media_throughput == 0.50
@@ -707,7 +707,7 @@ def test_execute_io_action() -> None:
707707
def test_execute_io_action2() -> None:
708708
experiment = "test_execute_io_action2"
709709

710-
with Silent(unit=unit, experiment=experiment, volume_ml=14.0) as ca:
710+
with Silent(unit=unit, experiment=experiment, current_volume_ml=14.0) as ca:
711711
results = ca.execute_io_action(media_ml=1.25, alt_media_ml=0.01, waste_ml=1.26)
712712
pause()
713713
assert results["media_ml"] == 1.25
@@ -1143,7 +1143,7 @@ def test_chemostat_from_0_volume() -> None:
11431143
unit,
11441144
experiment,
11451145
exchange_volume_ml=0.5,
1146-
volume_ml=0,
1146+
current_volume_ml=0,
11471147
) as chemostat:
11481148
pause(n=25)
11491149
assert chemostat.media_throughput == 0.5
@@ -1700,7 +1700,7 @@ def test_automation_will_pause_itself_if_pumping_goes_above_safety_threshold() -
17001700
experiment=experiment,
17011701
duration=0.05,
17021702
exchange_volume_ml=0.5,
1703-
volume_ml=Chemostat.MAX_VIAL_VOLUME_TO_STOP - 0.05,
1703+
current_volume_ml=Chemostat.MAX_VIAL_VOLUME_TO_STOP - 0.05,
17041704
) as job:
17051705
while job.state == "ready":
17061706
pause()
@@ -1807,7 +1807,7 @@ def test_dosing_automation_initial_values_for_volumes():
18071807
unit=unit,
18081808
experiment=exp,
18091809
alt_media_fraction=0.5,
1810-
volume_ml=10.0,
1810+
current_volume_ml=10.0,
18111811
max_working_volume_ml=15.0,
18121812
) as ca:
18131813
assert ca.current_volume_ml == 10.0
@@ -1821,7 +1821,7 @@ def test_dosing_automation_initial_values_for_volumes():
18211821
unit=unit,
18221822
experiment=exp,
18231823
alt_media_fraction=None,
1824-
volume_ml=None,
1824+
current_volume_ml=None,
18251825
max_working_volume_ml=16.0,
18261826
) as ca:
18271827
assert ca.current_volume_ml == 11.0

core/tests/test_growth_rate_calculating.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def create_od_raw_batched(channels, voltages: list[float], angles, timestamp: st
4141
for channel, voltage, angle in zip(channels, voltages, angles):
4242
assert int(channel) in (1, 2)
4343
readings.ods[channel] = structs.RawODReading(
44-
od=voltage, angle=angle, timestamp=to_datetime(timestamp), channel=channel
44+
od=voltage, angle=angle, timestamp=to_datetime(timestamp), channel=channel, ir_led_intensity=80
4545
)
4646

4747
return readings
@@ -937,7 +937,11 @@ def test_baseline_shift_gets_absorbed(self) -> None:
937937
)
938938
publish(
939939
f"pioreactor/{unit}/{experiment}/od_reading/od2",
940-
encode(structs.RawODReading(od=v, angle="90", timestamp=to_datetime(t), channel="2")),
940+
encode(
941+
structs.RawODReading(
942+
od=v, angle="90", timestamp=to_datetime(t), channel="2", ir_led_intensity=80
943+
)
944+
),
941945
retain=True,
942946
)
943947
time.sleep(0.5)
@@ -957,7 +961,11 @@ def test_baseline_shift_gets_absorbed(self) -> None:
957961
)
958962
publish(
959963
f"pioreactor/{unit}/{experiment}/od_reading/od2",
960-
encode(structs.RawODReading(od=v, angle="90", timestamp=to_datetime(t), channel="2")),
964+
encode(
965+
structs.RawODReading(
966+
od=v, angle="90", timestamp=to_datetime(t), channel="2", ir_led_intensity=80
967+
)
968+
),
961969
retain=True,
962970
)
963971
time.sleep(0.5)
@@ -1006,7 +1014,11 @@ def test_massive_outlier_spike_gets_absorbed(self) -> None:
10061014
)
10071015
publish(
10081016
f"pioreactor/{unit}/{experiment}/od_reading/od2",
1009-
encode(structs.RawODReading(od=v, angle="90", timestamp=to_datetime(t), channel="2")),
1017+
encode(
1018+
structs.RawODReading(
1019+
od=v, angle="90", timestamp=to_datetime(t), channel="2", ir_led_intensity=80
1020+
)
1021+
),
10101022
retain=True,
10111023
)
10121024
time.sleep(0.5)
@@ -1024,7 +1036,11 @@ def test_massive_outlier_spike_gets_absorbed(self) -> None:
10241036
)
10251037
publish(
10261038
f"pioreactor/{unit}/{experiment}/od_reading/od2",
1027-
encode(structs.RawODReading(od=v, angle="90", timestamp=to_datetime(t), channel="2")),
1039+
encode(
1040+
structs.RawODReading(
1041+
od=v, angle="90", timestamp=to_datetime(t), channel="2", ir_led_intensity=80
1042+
)
1043+
),
10281044
retain=True,
10291045
)
10301046
time.sleep(0.5)
@@ -1046,7 +1062,11 @@ def test_massive_outlier_spike_gets_absorbed(self) -> None:
10461062
)
10471063
publish(
10481064
f"pioreactor/{unit}/{experiment}/od_reading/od2",
1049-
encode(structs.RawODReading(od=v, angle="90", timestamp=to_datetime(t), channel="2")),
1065+
encode(
1066+
structs.RawODReading(
1067+
od=v, angle="90", timestamp=to_datetime(t), channel="2", ir_led_intensity=80
1068+
)
1069+
),
10501070
retain=True,
10511071
)
10521072
time.sleep(0.5)

core/tests/test_od_reading.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def test_sin_regression_all_negative() -> None:
595595

596596

597597
def test_simple_API() -> None:
598-
od_job = start_od_reading("90", "REF", interval=100_000, fake_data=True)
598+
od_job = start_od_reading("90", "REF", interval=100_000, fake_data=True, calibration=False)
599599

600600
for led_int in range(5, 70, 15):
601601
time.sleep(2)
@@ -1060,7 +1060,7 @@ def float_to_od_readings_struct(ch: pt.PdChannel, v: float) -> structs.ODReading
10601060
timestamp=current_utc_datetime(),
10611061
ods={
10621062
ch: structs.RawODReading(
1063-
ir_led_intensity=80, od=v, angle="90", channel=ch, timestamp=current_utc_datetime()
1063+
ir_led_intensity=70.0, od=v, angle="90", channel=ch, timestamp=current_utc_datetime()
10641064
)
10651065
},
10661066
)
@@ -1393,7 +1393,7 @@ def test_mandys_calibration() -> None:
13931393

13941394
def test_setting_interval_after_starting() -> None:
13951395
initial_interval = 2
1396-
with start_od_reading("90", "REF", interval=initial_interval, fake_data=True) as od:
1396+
with start_od_reading("90", "REF", interval=initial_interval, fake_data=True, calibration=False) as od:
13971397
next(od)
13981398
with catchtime() as c:
13991399
next(od)

web/tests/test_app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ def test_get_settings_api(client):
401401
with start_stirring(unit="unit1", experiment="exp1"):
402402
r = client.get("/api/workers/$broadcast/jobs/settings/job_name/stirring/experiments/exp1")
403403
# follow the task
404-
print(r.json)
405404
r = client.get(r.json["result_url_path"])
406405
settings_per_unit = r.json["result"]
407406
assert settings_per_unit["unit2"] is None
@@ -410,7 +409,6 @@ def test_get_settings_api(client):
410409
# next api
411410
r = client.get("/api/workers/unit1/jobs/settings/job_name/stirring/experiments/exp1")
412411
# follow the task
413-
print(r.json)
414412
r = client.get(r.json["result_url_path"])
415413
settings_per_unit = r.json["result"]
416414
assert settings_per_unit["unit1"]["settings"]["target_rpm"] == 500.0

0 commit comments

Comments
 (0)