Exemplo n.º 1
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
Exemplo n.º 2
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()