Exemplo n.º 1
0
 def _setup(self):
     """Setup the client."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
             'blacklist': ['fake.blacklisted']
         }
     }
     influxdb.setup(self.hass, config)
     self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
Exemplo n.º 2
0
 def _setup(self, mock_influx):
     self.mock_client = mock_influx.return_value
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     self.hass = mock.MagicMock()
     influxdb.setup(self.hass, config)
     self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
Exemplo n.º 3
0
 def _setup(self, mock_influx):
     self.mock_client = mock_influx.return_value
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     self.hass = mock.MagicMock()
     influxdb.setup(self.hass, config)
     self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
Exemplo n.º 4
0
 def _setup(self):
     """Setup the client."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
             'blacklist': ['fake.blacklisted']
         }
     }
     influxdb.setup(self.hass, config)
     self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
Exemplo n.º 5
0
 def test_setup_query_fail(self, mock_client):
     """Test the setup for query failures."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     mock_client.return_value.query.side_effect = \
         influx_client.exceptions.InfluxDBClientError('fake')
     self.assertFalse(influxdb.setup(self.hass, config))
Exemplo n.º 6
0
 def test_setup_query_fail(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     mock_client.return_value.query.side_effect = \
         influx_client.exceptions.InfluxDBClientError('fake')
     self.assertFalse(influxdb.setup(hass, config))
Exemplo n.º 7
0
 def test_setup_query_fail(self, mock_client):
     """Test the setup for query failures."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     mock_client.return_value.query.side_effect = \
         influx_client.exceptions.InfluxDBClientError('fake')
     self.assertFalse(influxdb.setup(self.hass, config))
Exemplo n.º 8
0
 def test_setup_query_fail(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     mock_client.return_value.query.side_effect = \
         influx_client.exceptions.InfluxDBClientError('fake')
     self.assertFalse(influxdb.setup(hass, config))
Exemplo n.º 9
0
 def test_setup_missing_keys(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     for missing in config['influxdb'].keys():
         config_copy = copy.deepcopy(config)
         del config_copy['influxdb'][missing]
         self.assertFalse(influxdb.setup(hass, config_copy))
Exemplo n.º 10
0
 def test_setup_config_defaults(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(influxdb.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
Exemplo n.º 11
0
 def test_setup_missing_keys(self, mock_client):
     """Test the setup with missing keys."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     for missing in config['influxdb'].keys():
         config_copy = copy.deepcopy(config)
         del config_copy['influxdb'][missing]
         self.assertFalse(influxdb.setup(self.hass, config_copy))
Exemplo n.º 12
0
 def test_setup_config_defaults(self, mock_client):
     """Test the setup with default configuration."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     self.assertTrue(influxdb.setup(self.hass, config))
     self.assertTrue(self.hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      self.hass.bus.listen.call_args_list[0][0][0])
Exemplo n.º 13
0
 def test_setup_config_defaults(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(influxdb.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
Exemplo n.º 14
0
 def test_setup_missing_keys(self, mock_client):
     """Test the setup with missing keys."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     for missing in config['influxdb'].keys():
         config_copy = copy.deepcopy(config)
         del config_copy['influxdb'][missing]
         self.assertFalse(influxdb.setup(self.hass, config_copy))
Exemplo n.º 15
0
 def test_setup_config_defaults(self, mock_client):
     """Test the setup with default configuration."""
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     self.assertTrue(influxdb.setup(self.hass, config))
     self.assertTrue(self.hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      self.hass.bus.listen.call_args_list[0][0][0])
Exemplo n.º 16
0
 def test_setup_missing_keys(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'username': '******',
             'password': '******',
         }
     }
     hass = mock.MagicMock()
     for missing in config['influxdb'].keys():
         config_copy = copy.deepcopy(config)
         del config_copy['influxdb'][missing]
         self.assertFalse(influxdb.setup(hass, config_copy))
Exemplo n.º 17
0
 def test_setup_config_full(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'port': 123,
             'database': 'db',
             'username': '******',
             'password': '******',
             'ssl': 'False',
             'verify_ssl': 'False',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(influxdb.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
     self.assertTrue(mock_client.return_value.query.called)
Exemplo n.º 18
0
 def test_setup_config_full(self, mock_client):
     """Test the setup with full configuration."""
     config = {
         'influxdb': {
             'host': 'host',
             'port': 123,
             'database': 'db',
             'username': '******',
             'password': '******',
             'ssl': 'False',
             'verify_ssl': 'False',
         }
     }
     self.assertTrue(influxdb.setup(self.hass, config))
     self.assertTrue(self.hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      self.hass.bus.listen.call_args_list[0][0][0])
     self.assertTrue(mock_client.return_value.query.called)
Exemplo n.º 19
0
 def test_setup_config_full(self, mock_client):
     """Test the setup with full configuration."""
     config = {
         'influxdb': {
             'host': 'host',
             'port': 123,
             'database': 'db',
             'username': '******',
             'password': '******',
             'ssl': 'False',
             'verify_ssl': 'False',
         }
     }
     self.assertTrue(influxdb.setup(self.hass, config))
     self.assertTrue(self.hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      self.hass.bus.listen.call_args_list[0][0][0])
     self.assertTrue(mock_client.return_value.query.called)
Exemplo n.º 20
0
 def test_setup_config_full(self, mock_client):
     config = {
         'influxdb': {
             'host': 'host',
             'port': 123,
             'database': 'db',
             'username': '******',
             'password': '******',
             'ssl': 'False',
             'verify_ssl': 'False',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(influxdb.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
     self.assertTrue(mock_client.return_value.query.called)