def test_message_id_clobbers_4th_data_bit():
    bc = BinaryCommand(1, 2, 2038004089, 9)
    s = bc.encode().decode()
    assert(s[0] == '\x01')
    assert(s[1] == '\x02')
    assert(s[2] == s[3] == s[4] == '\x79')
    assert(s[5] == '\x09')
def test_message_id_clobbers_4th_data_bit():
    bc = BinaryCommand(1, 2, 2038004089, 9)
    s = bc.encode().decode()
    assert (s[0] == '\x01')
    assert (s[1] == '\x02')
    assert (s[2] == s[3] == s[4] == '\x79')
    assert (s[5] == '\x09')
def test_encode_with_message_id():
    bc = BinaryCommand(1, 2, 3, 4)
    s = bc.encode().decode()
    assert(s[0] == '\x01')
    assert(s[1] == '\x02')
    assert(s[2] == '\x03')
    assert(s[3] == s[4] == '\x00')
    assert(s[5] == '\x04')
def test_encode_with_message_id():
    bc = BinaryCommand(1, 2, 3, 4)
    s = bc.encode().decode()
    assert (s[0] == '\x01')
    assert (s[1] == '\x02')
    assert (s[2] == '\x03')
    assert (s[3] == s[4] == '\x00')
    assert (s[5] == '\x04')
def test_encode():
    bc = BinaryCommand(1, 2, 3)
    # In this case encode() is not the inverse of decode().
    # encode() will convert from a BinaryCommand to "bytes",
    # and then decode will convert from bytes to unicode str.
    # The "decode()" call is only necessary to make this test
    # consistent in both Python 2 and 3.
    s = bc.encode().decode()
    assert(s[0] == '\x01')
    assert(s[1] == '\x02')
    assert(s[2] == '\x03')
    assert(s[3] == s[4] == s[5] == '\x00')
def test_encode():
    bc = BinaryCommand(1, 2, 3)
    # In this case encode() is not the inverse of decode().
    # encode() will convert from a BinaryCommand to "bytes",
    # and then decode will convert from bytes to unicode str.
    # The "decode()" call is only necessary to make this test
    # consistent in both Python 2 and 3.
    s = bc.encode().decode()
    assert (s[0] == '\x01')
    assert (s[1] == '\x02')
    assert (s[2] == '\x03')
    assert (s[3] == s[4] == s[5] == '\x00')
def test_write(binaryserial, fake):
    cmd = BinaryCommand(1, 54)
    binaryserial.write(cmd)
    fake.expect(cmd.encode())
Esempio n. 8
0
def test_write(binaryserial, fake):
    cmd = BinaryCommand(1, 54)
    binaryserial.write(cmd)
    fake.expect(cmd.encode())