Ejemplo n.º 1
0
 def test_ws_details_fail(self, caplog, api_mock):
     """Test WS get_details with Code>0"""
     self.mock_api.return_value = BAD_LIST
     vswitch15a = VeSyncWallSwitch(DEV_LIST_DETAIL, self.vesync_obj)
     vswitch15a.get_details()
     assert len(caplog.records) == 2
     assert 'details' in caplog.text
Ejemplo n.º 2
0
 def test_ws_details(self, api_mock):
     """Test WS get_details() """
     self.mock_api.return_value = CORRECT_WS_DETAILS
     wswitch = VeSyncWallSwitch(DEV_LIST_DETAIL, self.vesync_obj)
     wswitch.get_details()
     dev_details = wswitch.details
     assert wswitch.device_status == 'on'
     assert type(dev_details) == dict
     assert dev_details['active_time'] == 1
     assert wswitch.connection_status == 'online'
Ejemplo n.º 3
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
Ejemplo n.º 4
0
    def test_ws_onoff(self, caplog, api_mock):
        """Test 15A Device On/Off Methods"""
        self.mock_api.return_value = ({"code": 0}, 200)
        wswitch = VeSyncWallSwitch(DEV_LIST_DETAIL, self.vesync_obj)
        head = helpers.req_headers(self.vesync_obj)
        body = helpers.req_body(self.vesync_obj, 'devicestatus')

        body['status'] = 'on'
        body['uuid'] = wswitch.uuid
        on = wswitch.turn_on()
        self.mock_api.assert_called_with(
            '/inwallswitch/v1/device/devicestatus',
            'put',
            headers=head,
            json=body)
        assert on
        off = wswitch.turn_off()
        body['status'] = 'off'
        self.mock_api.assert_called_with(
            '/inwallswitch/v1/device/devicestatus',
            'put',
            headers=head,
            json=body)
        assert off
Ejemplo n.º 5
0
 def test_ws_onoff_fail(self, api_mock):
     """Test ws On/Off Fail with Code>0"""
     self.mock_api.return_value = ({"code": 1}, 400)
     vswitch15a = VeSyncWallSwitch(DEV_LIST_DETAIL, self.vesync_obj)
     assert not vswitch15a.turn_on()
     assert not vswitch15a.turn_off()