From 4e6c7bf125debb2f505522a6f4f96411a04c9814 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Fri, 15 Sep 2017 16:57:12 +0300 Subject: [PATCH] Fix tests --- pylgbst/comms.py | 7 +++++++ tests.py | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pylgbst/comms.py b/pylgbst/comms.py index be30221..28e7a56 100644 --- a/pylgbst/comms.py +++ b/pylgbst/comms.py @@ -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) diff --git a/tests.py b/tests.py index 43cded6..dc9a735 100644 --- a/tests.py +++ b/tests.py @@ -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)