1
0
mirror of https://github.com/undera/pylgbst.git synced 2020-11-18 19:37:26 -08:00

Fix tests

This commit is contained in:
Andrey Pokhilko 2017-09-15 16:57:12 +03:00
parent b40ee3ac1a
commit 4e6c7bf125
2 changed files with 16 additions and 5 deletions

View File

@ -283,3 +283,10 @@ class DebugServerConnection(Connection):
def set_notify_handler(self, handler):
self.notify_handler = handler
def start_debug_server(iface="hci0", port=9090):
ble = BLEConnection()
ble.connect(iface)
server = DebugServer(ble)
server.start(port)

View File

@ -70,7 +70,7 @@ class GeneralTest(unittest.TestCase):
hub = HubMock()
led = LED(hub, PORT_LED)
led.set_color(COLOR_RED)
self.assertEqual("0801813211510009", hub.connection.writes[0][1])
self.assertEqual("0801813201510009", hub.connection.writes[0][1])
def test_tilt_sensor(self):
hub = HubMock()
@ -104,10 +104,14 @@ class GeneralTest(unittest.TestCase):
conn = ConnectionMock()
conn.notifications.append((14, '1b0e00 0900 04 39 0227003738'))
hub = HubMock(conn)
motor = EncodedMotor(hub, PORT_AB)
motor.timed(1.5)
time.sleep(0.1)
conn.notifications.append((14, '1b0e00050082390a'))
hub.motor_AB.timed(1.5)
self.assertEqual("0d018139110adc056464647f03", conn.writes[0][1])
motor.angled(90)
conn.notifications.append((14, '1b0e00050082390a'))
hub.motor_AB.angled(90)
self.assertEqual("0f018139110c5a0000006464647f03", conn.writes[1][1])
def test_capabilities(self):
@ -134,7 +138,7 @@ class GeneralTest(unittest.TestCase):
hub.connection.notifications.append((HANDLE, '1b0e000f0004010125000000001000000010'))
time.sleep(1)
def callback(color, unk1, unk2):
def callback(color, unk1, unk2=None):
name = COLORS[color] if color is not None else 'NONE'
log.info("Color: %s %s %s", name, unk1, unk2)