20 lines
653 B
Python
20 lines
653 B
Python
# tests/test_power_supply.py
|
|
"""
|
|
Basic functional tests for the PowerSupply
|
|
"""
|
|
|
|
def test_set_and_measure_voltage(power_supply):
|
|
test_voltage = 5.0
|
|
power_supply.set_voltage(test_voltage)
|
|
measured = power_supply.measure_voltage()
|
|
assert abs(measured - test_voltage) < 0.05
|
|
|
|
def test_output_toggle(power_supply):
|
|
power_supply.enable_output(True)
|
|
# Only works for DummyBackend which keeps state
|
|
if hasattr(power_supply.comm, "state"):
|
|
assert power_supply.comm.state["OUTP"] is True
|
|
|
|
power_supply.enable_output(False)
|
|
if hasattr(power_supply.comm, "state"):
|
|
assert power_supply.comm.state["OUTP"] is False |