Esempio n. 1
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) == 2
     assert 'details' in caplog.text
Esempio n. 2
0
    def test_display_func(self, caplog, api_mock):
        """Test display function outputs text."""
        self.vesync_obj.outlets.append(
            VeSyncOutdoorPlug(json_vals.LIST_CONF_OUTDOOR_1, self.vesync_obj))
        self.vesync_obj.outlets.append(
            VeSyncOutlet10A(json_vals.LIST_CONF_10AUS, self.vesync_obj))
        self.vesync_obj.outlets.append(
            VeSyncOutlet15A(json_vals.LIST_CONF_15A, self.vesync_obj))
        self.vesync_obj.outlets.append(
            VeSyncOutlet7A(json_vals.LIST_CONF_7A, self.vesync_obj))
        self.vesync_obj.switches.append(
            VeSyncWallSwitch(json_vals.LIST_CONF_WS, self.vesync_obj))
        self.vesync_obj.fans.append(
            VeSyncAir131(json_vals.LIST_CONF_AIR, self.vesync_obj))
        self.vesync_obj.bulbs.append(
            VeSyncBulbESL100(json_vals.LIST_CONF_ESL100, self.vesync_obj))

        dev_list = [
            self.vesync_obj.outlets, self.vesync_obj.switches,
            self.vesync_obj.fans, self.vesync_obj.bulbs
        ]

        for device in chain(*dev_list):
            device.display()

        assert len(caplog.records) == 0
Esempio n. 3
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=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=body,
         headers=head)
     assert off
Esempio n. 4
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
Esempio n. 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
Esempio n. 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 type(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'
Esempio n. 7
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)
     vswitch15a = VeSyncAir131(DEV_LIST_DETAIL, self.vesync_obj)
     assert not vswitch15a.turn_on()
     assert not vswitch15a.turn_off()