def test_is_toggle(arduino: Mock, led: DimmableLED) -> None: led.toggle() led.toggle() assert arduino.analog_write.call_args_list == [ call(PIN_NUM, 0, TOKEN), call(PIN_NUM, 255, TOKEN), call(PIN_NUM, 0, TOKEN), ]
def test_brightness_when_on(arduino: Mock, led: DimmableLED) -> None: led.turn_on() led.brightness = 100 assert arduino.analog_write.call_args_list == [ call(PIN_NUM, 0, TOKEN), call(PIN_NUM, 255, TOKEN), call(PIN_NUM, 100, TOKEN), ] assert led.brightness == 100
def test_non_default_brightness_is_set_when_turning_on( arduino: Mock, led: DimmableLED ) -> None: led.brightness = 100 led.turn_on() assert arduino.analog_write.call_args_list == [ call(PIN_NUM, 0, TOKEN), call(PIN_NUM, 100, TOKEN), ] assert led.brightness == 100
def test_is_on(arduino: Mock, led: DimmableLED) -> None: assert led.is_on() is False led.turn_on() assert led.is_on() is True
def test_turn_off(arduino: Mock, led: DimmableLED) -> None: led.turn_off() assert arduino.analog_write.call_args_list == [ call(PIN_NUM, 0, TOKEN), call(PIN_NUM, 0, TOKEN), ]
def led(arduino: Arduino) -> DimmableLED: return DimmableLED(arduino, PIN_NUM)