Esempio n. 1
0
def test_echo_too_long():
    serial = MockSerial(b'')

    attiny = AttinyProtocol(serial)

    with pytest.raises(InvalidLengthException):
        attiny.echo(b'abcd')

    assert serial.received == b''
Esempio n. 2
0
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
Esempio n. 3
0
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