Exemple #1
0
def test_set_right_motor_invalid():
    serial = MockSerial(INVALID_RESPONSE)

    attiny = AttinyProtocol(serial)
    with pytest.raises(InvalidResponseException):
        attiny.set_right_motor(0)

    assert serial.received[:1] == SET_RIGHT_MOTOR
Exemple #2
0
def test_set_right_motor_nak():
    serial = MockSerial(NAK)

    attiny = AttinyProtocol(serial)
    result = attiny.set_right_motor(0)

    assert result == False
Exemple #3
0
def test_set_right_motor_timeout():
    serial = MockSerial(b'')

    attiny = AttinyProtocol(serial)
    result = attiny.set_right_motor(0)

    assert result == False
Exemple #4
0
def test_set_right_motor_zero():
    serial = MockSerial(ACK)

    right = MOTOR_ZERO
    right_bytes = BYTES_MOTOR_ZERO

    attiny = AttinyProtocol(serial)
    result = attiny.set_right_motor(right)

    assert len(serial.received) == 2
    assert serial.received == SET_RIGHT_MOTOR + right_bytes

    assert result == True