Esempio n. 1
0
 def test_device_list(self):
     device_list = DeviceList([DeviceInfo("TestDevice1",
                                          0,
                                          {"SingleMotorVibrateCmd": {},
                                           "VibrateCmd": {"FeatureCount": 2},
                                           "StopDeviceCmd": {},
                                          }),
                               DeviceInfo("TestDevice2",
                                          1,
                                          {"FleshlightLaunchFW12Cmd": {},
                                           "LinearCmd": {"FeatureCount": 1},
                                           "StopDeviceCmd": {}})])
     json_msg = "{\"DeviceList\": {\"Devices\": [{\"DeviceName\": \"TestDevice1\", \"DeviceIndex\": 0, \"DeviceMessages\": {\"SingleMotorVibrateCmd\": {}, \"VibrateCmd\": {\"FeatureCount\": 2}, \"StopDeviceCmd\": {}}}, {\"DeviceName\": \"TestDevice2\", \"DeviceIndex\": 1, \"DeviceMessages\": {\"FleshlightLaunchFW12Cmd\": {}, \"LinearCmd\": {\"FeatureCount\": 1}, \"StopDeviceCmd\": {}}}], \"Id\": 1}}"
     self.run_msg_test(device_list,  json_msg)
async def test_device_linear_list():
    client = DummyClient()
    dev = ButtplugClientDevice(client, DeviceInfo("Test Rotation Device",
                                                  0,
                                                  {"LinearCmd":
                                                   {"FeatureCount": 1}}))
    await dev.send_linear_cmd([(1000, 1.0)])
    assert client.last_message == LinearCmd(0, [LinearSubcommand(0, 1000, 1.0)])
async def test_device_rotate_dict():
    client = DummyClient()
    dev = ButtplugClientDevice(client, DeviceInfo("Test Rotation Device",
                                                  0,
                                                  {"RotateCmd":
                                                   {"FeatureCount": 1}}))
    await dev.send_rotate_cmd({0: (1.0, True)})
    assert client.last_message == RotateCmd(0, [RotateSubcommand(0, 1.0, True)])
async def test_device_vibrate_dict():
    client = DummyClient()
    dev = ButtplugClientDevice(client, DeviceInfo("Test Vibration Device",
                                                  0,
                                                  {"VibrateCmd":
                                                   {"FeatureCount": 1}}))
    await dev.send_vibrate_cmd({0: 1.0})
    assert client.last_message == VibrateCmd(0, [SpeedSubcommand(0, 1.0)])