mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Fix tests
This commit is contained in:
parent
b40ee3ac1a
commit
4e6c7bf125
@ -283,3 +283,10 @@ class DebugServerConnection(Connection):
|
|||||||
|
|
||||||
def set_notify_handler(self, handler):
|
def set_notify_handler(self, handler):
|
||||||
self.notify_handler = handler
|
self.notify_handler = handler
|
||||||
|
|
||||||
|
|
||||||
|
def start_debug_server(iface="hci0", port=9090):
|
||||||
|
ble = BLEConnection()
|
||||||
|
ble.connect(iface)
|
||||||
|
server = DebugServer(ble)
|
||||||
|
server.start(port)
|
||||||
|
14
tests.py
14
tests.py
@ -70,7 +70,7 @@ class GeneralTest(unittest.TestCase):
|
|||||||
hub = HubMock()
|
hub = HubMock()
|
||||||
led = LED(hub, PORT_LED)
|
led = LED(hub, PORT_LED)
|
||||||
led.set_color(COLOR_RED)
|
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):
|
def test_tilt_sensor(self):
|
||||||
hub = HubMock()
|
hub = HubMock()
|
||||||
@ -104,10 +104,14 @@ class GeneralTest(unittest.TestCase):
|
|||||||
conn = ConnectionMock()
|
conn = ConnectionMock()
|
||||||
conn.notifications.append((14, '1b0e00 0900 04 39 0227003738'))
|
conn.notifications.append((14, '1b0e00 0900 04 39 0227003738'))
|
||||||
hub = HubMock(conn)
|
hub = HubMock(conn)
|
||||||
motor = EncodedMotor(hub, PORT_AB)
|
time.sleep(0.1)
|
||||||
motor.timed(1.5)
|
|
||||||
|
conn.notifications.append((14, '1b0e00050082390a'))
|
||||||
|
hub.motor_AB.timed(1.5)
|
||||||
self.assertEqual("0d018139110adc056464647f03", conn.writes[0][1])
|
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])
|
self.assertEqual("0f018139110c5a0000006464647f03", conn.writes[1][1])
|
||||||
|
|
||||||
def test_capabilities(self):
|
def test_capabilities(self):
|
||||||
@ -134,7 +138,7 @@ class GeneralTest(unittest.TestCase):
|
|||||||
hub.connection.notifications.append((HANDLE, '1b0e000f0004010125000000001000000010'))
|
hub.connection.notifications.append((HANDLE, '1b0e000f0004010125000000001000000010'))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
def callback(color, unk1, unk2):
|
def callback(color, unk1, unk2=None):
|
||||||
name = COLORS[color] if color is not None else 'NONE'
|
name = COLORS[color] if color is not None else 'NONE'
|
||||||
log.info("Color: %s %s %s", name, unk1, unk2)
|
log.info("Color: %s %s %s", name, unk1, unk2)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user