Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 28, 2023
1 parent 8305bab commit a5a4636
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
4 changes: 3 additions & 1 deletion pioreactor/automations/led/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def set_duration(self, duration: float) -> None:
# there is a race condition here: self.run() will run immediately (see run_immediately), but the state of the job is not READY, since
# set_duration is run in the __init__ (hence the job is INIT). So we wait 2 seconds for the __init__ to finish, and then run.
# Later: in fact, we actually want this to run after an OD reading cycle so we have internal data, so it should wait a cycle of that.
run_after = 1.0 / config.getfloat("od_config", "samples_per_second")
run_after = max(
1.0 / config.getfloat("od_config", "samples_per_second"), 10
) # max so users aren't waiting forever to see lights come on...

self.run_thread = RepeatedTimer(
self.duration * 60, # RepeatedTimer uses seconds
Expand Down
4 changes: 2 additions & 2 deletions pioreactor/tests/test_led_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_light_dark_cycle_starts_on() -> None:
unit=unit,
experiment=experiment,
) as lc:
pause(6)
pause(12)

assert lc.automation_job.light_active
with local_intermittent_storage("leds") as c:
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_light_duration_hour_to_zero() -> None:
unit=unit,
experiment=experiment,
) as lc:
pause(6)
pause(12)
assert lc.automation_job.light_active

lc.automation_job.set_light_duration_minutes(60 * 0)
Expand Down
16 changes: 0 additions & 16 deletions pioreactor/tests/test_temperature_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,6 @@ def test_child_cant_update_heater_when_locked() -> None:
assert t.automation_job.update_heater(50)


def test_constant_duty_cycle_init() -> None:
experiment = "test_constant_duty_cycle_init"
pubsub.publish(
f"pioreactor/{unit}/{experiment}/temperature_control/temperature",
None,
retain=True,
)

dc = 50
with temperature_control.TemperatureController(
automation_name="constant_duty_cycle", unit=unit, experiment=experiment, duty_cycle=dc
) as algo:
pause()
assert algo.heater_duty_cycle == 50


def test_setting_pid_control_after_startup_will_start_some_heating() -> None:
# this test tries to replicate what a user does in the UI
experiment = "test_setting_pid_control_after_startup_will_start_some_heating"
Expand Down

0 comments on commit a5a4636

Please sign in to comment.