示例#1
0
def test_set_left_motor_invalid():
    serial = MockSerial(INVALID_RESPONSE)

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

    assert serial.received[:1] == SET_LEFT_MOTOR
示例#2
0
def test_set_left_motor_nak():
    serial = MockSerial(NAK)

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

    assert result == False
示例#3
0
def test_set_left_motor_timeout():
    serial = MockSerial(b'')

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

    assert result == False
示例#4
0
def test_set_left_motor_zero():
    serial = MockSerial(ACK)

    left = MOTOR_ZERO
    left_bytes = BYTES_MOTOR_ZERO

    attiny = AttinyProtocol(serial)
    result = attiny.set_left_motor(left)

    assert len(serial.received) == 2
    assert serial.received == SET_LEFT_MOTOR + left_bytes

    assert result == True