def test_echo_too_long(): serial = MockSerial(b'') attiny = AttinyProtocol(serial) with pytest.raises(InvalidLengthException): attiny.echo(b'abcd') assert serial.received == b''
def test_echo_invalid(): serial = MockSerial(ECHO_INVALID) attiny = AttinyProtocol(serial) with pytest.raises(InvalidResponseException): attiny.echo(ECHO_TEST) assert serial.received == ECHO + ECHO_TEST
def test_echo(): serial = MockSerial(ECHO_TEST) attiny = AttinyProtocol(serial) response = attiny.echo(ECHO_TEST) assert serial.received == ECHO + ECHO_TEST assert response == ECHO_TEST