示例#1
0
 def test_airpur_onoff(self, caplog, api_mock):
     """Test Air Purifier Device On/Off Methods."""
     self.mock_api.return_value = ({'code': 0}, 200)
     fan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     head = helpers.req_headers(self.vesync_obj)
     body = helpers.req_body(self.vesync_obj, 'devicestatus')
     fan.device_status = 'off'
     body['status'] = 'on'
     body['uuid'] = fan.uuid
     on = fan.turn_on()
     self.mock_api.assert_called_with(
         '/131airPurifier/v1/device/deviceStatus',
         'put',
         json_object=body,
         headers=head)
     call_args = self.mock_api.call_args_list[0][0]
     assert call_args[0] == '/131airPurifier/v1/device/deviceStatus'
     assert call_args[1] == 'put'
     assert on
     fan.device_status = 'on'
     off = fan.turn_off()
     body['status'] = 'off'
     self.mock_api.assert_called_with(
         '/131airPurifier/v1/device/deviceStatus',
         'put',
         json_object=body,
         headers=head)
     assert off
示例#2
0
 def test_airpur_details_fail(self, caplog, api_mock):
     """Test Air Purifier get_details with Code>0."""
     self.mock_api.return_value = BAD_LIST
     fan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     fan.get_details()
     assert len(caplog.records) == 1
     assert 'details' in caplog.text
示例#3
0
 def test_mode_toggle(self, caplog, api_mock):
     """Test changing modes on air purifier."""
     self.mock_api.return_value = ({'code': 0}, 200)
     fan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     f = fan.auto_mode()
     assert f
     assert fan.mode == 'auto'
     f = fan.manual_mode()
     assert fan.mode == 'manual'
     assert f
     f = fan.sleep_mode()
     assert fan.mode == 'sleep'
     assert f
示例#4
0
 def getDevice(device_type, config, manager):
     if device_type == 'wifi-switch-1.3':
         return VeSyncOutlet7A(config, manager)
     elif device_type in ['ESW03-USA', 'ESW01-EU']:
         return VeSyncOutlet10A(config, manager)
     elif device_type == 'ESW15-USA':
         return VeSyncOutlet15A(config, manager)
     elif device_type in ['ESWL01', 'ESWL03']:
         return VeSyncWallSwitch(config, manager)
     elif device_type == 'LV-PUR131S':
         return VeSyncAir131(config, manager)
     else:
         logger.debug('Unknown device found - ' + device_type)
示例#5
0
 def test_airpur_fanspeed(self, caplog, api_mock):
     """Test changing fan speed of."""
     self.mock_api.return_value = ({'code': 0}, 200)
     fan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     fan.details['level'] = 1
     b = fan.change_fan_speed()
     assert fan.fan_level == 2
     b = fan.change_fan_speed()
     assert fan.fan_level == 3
     b = fan.change_fan_speed()
     assert fan.fan_level == 1
     assert b
     b = fan.change_fan_speed(2)
     assert b
     assert fan.fan_level == 2
示例#6
0
 def test_airpur_details(self, api_mock):
     """Test 15A get_details()."""
     self.mock_api.return_value = CORRECT_DETAILS
     fan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     fan.get_details()
     dev_details = fan.details
     assert fan.device_status == 'on'
     assert isinstance(dev_details, dict)
     assert dev_details['active_time'] == 1
     assert fan.filter_life == 100
     assert dev_details['screen_status'] == 'on'
     assert fan.mode == 'manual'
     assert dev_details['level'] == 1
     assert fan.fan_level == 1
     assert dev_details['air_quality'] == 'excellent'
     assert fan.air_quality == 'excellent'
示例#7
0
def get_device(device_type, config, manager):
    """Return initilized device from API response."""
    if device_type == 'wifi-switch-1.3':
        return VeSyncOutlet7A(config, manager)
    if device_type in ['ESW03-USA', 'ESW01-EU']:
        return VeSyncOutlet10A(config, manager)
    if device_type == 'ESW15-USA':
        return VeSyncOutlet15A(config, manager)
    if device_type in ['ESWL01', 'ESWL03']:
        return VeSyncWallSwitch(config, manager)
    if device_type == 'LV-PUR131S':
        return VeSyncAir131(config, manager)
    if device_type == 'ESO15-TB':
        return VeSyncOutdoorPlug(config, manager)
    if device_type == 'ESL100':
        return VeSyncBulbESL100(config, manager)
    if device_type == 'ESL100CW':
        return VeSyncBulbESL100CW(config, manager)
    if device_type == 'ESWD16':
        return VeSyncDimmerSwitch(config, manager)
    logger.debug('Unknown device found - %s', device_type)
    return None
示例#8
0
 def test_airpur_onoff_fail(self, api_mock):
     """Test Air Purifier On/Off Fail with Code>0."""
     self.mock_api.return_value = ({'code': 1}, 400)
     vsfan = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     assert not vsfan.turn_on()
     assert not vsfan.turn_off()