Example #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]
Example #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]
Example #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]
Example #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]
Example #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))
Example #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))
Example #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))
Example #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))
Example #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))
Example #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])
Example #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))
Example #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])
Example #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])
Example #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))
Example #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])
Example #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))
Example #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)
Example #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)
Example #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)
Example #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)