Exemple #1
0
 def _setup(self, mock_requests):
     self.mock_post = mock_requests.post
     self.mock_request_exception = Exception
     mock_requests.exceptions.RequestException = self.mock_request_exception
     config = {
         'splunk': {
             'host': 'host',
             'token': 'secret',
         }
     }
     self.hass = mock.MagicMock()
     splunk.setup(self.hass, config)
     self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
Exemple #2
0
 def test_setup_config_defaults(self):
     config = {
         'splunk': {
             'host': 'host',
             'token': 'secret',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(splunk.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
Exemple #3
0
 def test_setup_config_full(self):
     """Test setup with all data."""
     config = {
         'splunk': {
             'host': 'host',
             'port': 123,
             'token': 'secret',
             'use_ssl': 'False',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(splunk.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])
Exemple #4
0
 def test_setup_config_full(self):
     """Test setup with all data."""
     config = {
         'splunk': {
             'host': 'host',
             'port': 123,
             'token': 'secret',
             'use_ssl': 'False',
         }
     }
     hass = mock.MagicMock()
     self.assertTrue(splunk.setup(hass, config))
     self.assertTrue(hass.bus.listen.called)
     self.assertEqual(EVENT_STATE_CHANGED,
                      hass.bus.listen.call_args_list[0][0][0])