34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
|
|
import json
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from polisher_control.contracts import SpindleDirection, normalize_spindle_direction
|
||
|
|
from polisher_control.telemetry_channels import RECOMMENDED_CHANNELS
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parents[1]
|
||
|
|
|
||
|
|
|
||
|
|
def test_spindle_direction_enum_uses_stable_wire_values():
|
||
|
|
assert SpindleDirection.CLOCKWISE.value == "cw"
|
||
|
|
assert SpindleDirection.COUNTER_CLOCKWISE.value == "ccw"
|
||
|
|
assert SpindleDirection.allowed_values() == ["cw", "ccw"]
|
||
|
|
|
||
|
|
|
||
|
|
def test_normalize_spindle_direction_accepts_operator_aliases():
|
||
|
|
assert normalize_spindle_direction("cw") == SpindleDirection.CLOCKWISE
|
||
|
|
assert normalize_spindle_direction("clockwise") == SpindleDirection.CLOCKWISE
|
||
|
|
assert normalize_spindle_direction("ccw") == SpindleDirection.COUNTER_CLOCKWISE
|
||
|
|
assert normalize_spindle_direction("counter-clockwise") == SpindleDirection.COUNTER_CLOCKWISE
|
||
|
|
|
||
|
|
|
||
|
|
def test_spindle_direction_is_in_controller_job_segment_schema():
|
||
|
|
schema = json.loads((ROOT / "shared/schemas/controller-job.schema.json").read_text())
|
||
|
|
segment = schema["$defs"]["segment"]
|
||
|
|
|
||
|
|
assert "commanded_spindle_direction" in segment["required"]
|
||
|
|
assert segment["properties"]["commanded_spindle_direction"]["enum"] == ["cw", "ccw"]
|
||
|
|
|
||
|
|
|
||
|
|
def test_spindle_direction_is_logged_as_telemetry_context():
|
||
|
|
assert "spindle_direction_setpoint" in RECOMMENDED_CHANNELS
|
||
|
|
assert "spindle_direction_actual" in RECOMMENDED_CHANNELS
|