def test_dyson_state_hot(self):
     dyson_state = DysonState(Hot,
                              open("tests/data/state_hot.json", "r").read())
     self.assertEqual(dyson_state.fan_mode, FanMode.AUTO.value)
     self.assertEqual(dyson_state.fan_state, FanState.FAN_ON.value)
     self.assertEqual(dyson_state.night_mode, NightMode.NIGHT_MODE_ON.value)
     self.assertEqual(dyson_state.speed, FanSpeed.FAN_SPEED_AUTO.value)
     self.assertEqual(dyson_state.oscillation,
                      Oscillation.OSCILLATION_OFF.value)
     self.assertEqual(dyson_state.filter_life, '2087')
     self.assertEqual(dyson_state.heat_mode, HeatMode.HEAT_ON.value)
     self.assertEqual(dyson_state.heat_state, HeatState.HEAT_STATE_ON.value)
     self.assertEqual(dyson_state.tilt, TiltState.TILT_FALSE.value)
     self.assertEqual(dyson_state.focus_mode, FocusMode.FOCUS_ON.value)
     self.assertEqual(dyson_state.heat_target, '2950')
     self.assertEqual(dyson_state.__repr__(),
                      "DysonState(fan_mode=AUTO,fan_state=FAN,"
                      "night_mode=ON,speed=AUTO,oscillation=OFF,"
                      "filter_life=2087,quality_target=0004,"
                      "standby_monitoring=ON,tilt=OK,focus_mode=ON,"
                      "heat_mode=HEAT,heat_target=2950,heat_state=HEAT)")
     self.assertEqual(dyson_state.quality_target,
                      QualityTarget.QUALITY_NORMAL.value)
     self.assertEqual(dyson_state.standby_monitoring,
                      SM.STANDBY_MONITORING_ON.value)
示例#2
0
 def test_dyson_state(self):
     dyson_state = DysonState(open("tests/data/state.json", "r").read())
     self.assertEqual(dyson_state.fan_mode, FanMode.AUTO.value)
     self.assertEqual(dyson_state.fan_state, FanState.FAN_ON.value)
     self.assertEqual(dyson_state.night_mode, NightMode.NIGHT_MODE_ON.value)
     self.assertEqual(dyson_state.speed, FanSpeed.FAN_SPEED_AUTO.value)
     self.assertEqual(dyson_state.oscillation,
                      Oscillation.OSCILLATION_OFF.value)
     self.assertEqual(dyson_state.filter_life, '2087')
     self.assertEqual(dyson_state.__repr__(),
                      "DysonState(AUTO,FAN,ON,AUTO,OFF,2087,0004,ON)")
 def test_dont_set_configuration_if_not_connected(self, mocked_connect,
                                                  mocked_publish):
     device = DysonPureCoolLink({
         "Active": True,
         "Serial": "device-id-1",
         "Name": "device-1",
         "ScaleUnit": "SU01",
         "Version": "21.03.08",
         "LocalCredentials": "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/70ZGysII1K"
                             "e1i0ZHakFH84DZuxsSQ4KTT2vbCm7uYeTORULKLKQ==",
         "AutoUpdate": True,
         "NewVersionAvailable": False,
         "ProductType": "475"
     })
     network_device = NetworkDevice('device-1', 'host', 1111)
     device._add_network_device(network_device)
     device._current_state = DysonState(Desk, open("tests/data/state.json",
                                                   "r").read())
     device.connection_callback(False)
     connected = device.connect(None)
     self.assertFalse(connected)
     self.assertEqual(mocked_connect.call_count, 1)
     device.set_configuration(fan_mode=FanMode.FAN,
                              oscillation=Oscillation.OSCILLATION_ON,
                              fan_speed=FanSpeed.FAN_SPEED_3,
                              night_mode=NightMode.NIGHT_MODE_OFF)
     self.assertEqual(mocked_publish.call_count, 0)
     self.assertEqual(device.__repr__(),
                      "DysonDevice(serial=device-id-1,active=True,"
                      "name=device-1,version=21.03.08,auto_update=True,"
                      "new_version_available=False,product_type=475,"
                      "network_device=NetworkDevice(name=device-1,"
                      "address=host,port=1111))")
 def test_set_configuration_timer_off(self, mocked_connect, mocked_publish):
     device = DysonPureCoolLink({
         "Active": True,
         "Serial": "device-id-1",
         "Name": "device-1",
         "ScaleUnit": "SU01",
         "Version": "21.03.08",
         "LocalCredentials": "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/70ZGysII1K"
                             "e1i0ZHakFH84DZuxsSQ4KTT2vbCm7uYeTORULKLKQ==",
         "AutoUpdate": True,
         "NewVersionAvailable": False,
         "ProductType": "475"
     })
     network_device = NetworkDevice('device-1', 'host', 1111)
     device._add_network_device(network_device)
     device._current_state = DysonState(Desk, open("tests/data/state.json",
                                                   "r").read())
     device.connection_callback(True)
     device.state_data_available()
     device.sensor_data_available()
     connected = device.connect(None)
     self.assertTrue(connected)
     self.assertEqual(mocked_connect.call_count, 1)
     device.set_configuration(sleep_timer=0)
     self.assertEqual(mocked_publish.call_count, 3)
     self.assertEqual(device.__repr__(),
                      "DysonDevice(serial=device-id-1,active=True,"
                      "name=device-1,version=21.03.08,auto_update=True,"
                      "new_version_available=False,product_type=475,"
                      "network_device=NetworkDevice(name=device-1,"
                      "address=host,port=1111))")
     device.disconnect()
 def test_dyson_state(self):
     dyson_state = DysonState(Desk,
                              open("tests/data/state.json", "r").read())
     self.assertEqual(dyson_state.fan_mode, FanMode.AUTO.value)
     self.assertEqual(dyson_state.fan_state, FanState.FAN_ON.value)
     self.assertEqual(dyson_state.night_mode, NightMode.NIGHT_MODE_ON.value)
     self.assertEqual(dyson_state.speed, FanSpeed.FAN_SPEED_AUTO.value)
     self.assertEqual(dyson_state.oscillation,
                      Oscillation.OSCILLATION_OFF.value)
     self.assertEqual(dyson_state.filter_life, '2087')
     self.assertEqual(dyson_state.__repr__(),
                      "DysonState(fan_mode=AUTO,fan_state=FAN,"
                      "night_mode=ON,speed=AUTO,oscillation=OFF,"
                      "filter_life=2087,quality_target=0004,"
                      "standby_monitoring=ON)")
     self.assertEqual(dyson_state.quality_target,
                      QualityTarget.QUALITY_NORMAL.value)
     self.assertEqual(dyson_state.standby_monitoring,
                      SM.STANDBY_MONITORING_ON.value)
 def test_set_configuration_hot(self, mocked_connect, mocked_publish):
     device = DysonPureCoolLink({
         "Active": True,
         "Serial": "device-id-1",
         "Name": "device-1",
         "ScaleUnit": "SU01",
         "Version": "21.03.08",
         "LocalCredentials": "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/70ZGysII1K"
                             "e1i0ZHakFH84DZuxsSQ4KTT2vbCm7uYeTORULKLKQ==",
         "AutoUpdate": True,
         "NewVersionAvailable": False,
         "ProductType": Hot
     })
     network_device = NetworkDevice('device-1', 'host', 1111)
     device._add_network_device(network_device)
     device._current_state = DysonState(Hot,
                                        open("tests/data/state_hot.json",
                                             "r").read())
     device.connection_callback(True)
     device.state_data_available()
     device.sensor_data_available()
     connected = device.connect(None)
     self.assertTrue(connected)
     self.assertEqual(mocked_connect.call_count, 1)
     device.set_configuration(fan_mode=FanMode.FAN,
                              oscillation=Oscillation.OSCILLATION_ON,
                              fan_speed=FanSpeed.FAN_SPEED_3,
                              night_mode=NightMode.NIGHT_MODE_OFF,
                              quality_target=QualityTarget.QUALITY_NORMAL,
                              standby_monitoring=SM.STANDBY_MONITORING_ON,
                              heat_mode=HeatMode.HEAT_ON,
                              focus_mode=FocusMode.FOCUS_ON,
                              heat_target=HeatTarget.celsius(25)
                              )
     self.assertEqual(mocked_publish.call_count, 3)
     self.assertEqual(device.__repr__(),
                      "DysonDevice(serial=device-id-1,active=True,"
                      "name=device-1,version=21.03.08,auto_update=True,"
                      "new_version_available=False,product_type=455,"
                      "network_device=NetworkDevice(name=device-1,"
                      "address=host,port=1111))")
     device.disconnect()
 def test_set_configuration_rst_filter(self, mocked_connect,
                                       mocked_publish):
     device = DysonPureCoolLink({
         "Active": True,
         "Serial": "device-id-1",
         "Name": "device-1",
         "ScaleUnit": "SU01",
         "Version": "21.03.08",
         "LocalCredentials": "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/70ZGysII1K"
                             "e1i0ZHakFH84DZuxsSQ4KTT2vbCm7uYeTORULKLKQ==",
         "AutoUpdate": True,
         "NewVersionAvailable": False,
         "ProductType": "475"
     })
     network_device = NetworkDevice('device-1', 'host', 1111)
     device._add_network_device(network_device)
     device._current_state = DysonState(open("tests/data/state.json", "r").
                                        read())
     device.connection_callback(True)
     device.state_data_available()
     device.sensor_data_available()
     connected = device.connect(None)
     self.assertTrue(connected)
     self.assertEqual(mocked_connect.call_count, 1)
     device.set_configuration(fan_mode=FanMode.FAN,
                              oscillation=Oscillation.OSCILLATION_ON,
                              fan_speed=FanSpeed.FAN_SPEED_3,
                              night_mode=NightMode.NIGHT_MODE_OFF,
                              quality_target=QualityTarget.QUALITY_NORMAL,
                              standby_monitoring=SM.STANDBY_MONITORING_ON,
                              reset_filter=ResetFilter.RESET_FILTER
                              )
     self.assertEqual(mocked_publish.call_count, 3)
     self.assertEqual(device.__repr__(),
                      "DysonDevice(device-id-1,True,device-1,21.03.08,True"
                      ",False,475,NetworkDevice(device-1,host,1111))")
     device.disconnect()