Refactor: rename SimDUT, restructure DUT simulation and test flow
This commit is contained in:
14
tests/test_dut.py
Normal file
14
tests/test_dut.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# tests/test_dut.py
|
||||
|
||||
import pytest
|
||||
|
||||
def test_dut_version(dut):
|
||||
"""Ensure the DUT returns a version string in sim mode."""
|
||||
version = dut.get_version()
|
||||
assert version.startswith("sim-")
|
||||
|
||||
def test_dut_temperature(dut):
|
||||
"""Test readback of simulated temperature."""
|
||||
temp = dut.read_temperature()
|
||||
assert 20 <= temp <= 100 # Acceptable range
|
||||
|
||||
20
tests/test_power_supply.py
Normal file
20
tests/test_power_supply.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user