Exemple #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''
Exemple #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
Exemple #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