Esempio n. 1
0
 def test_execute_with_access(self):
     with requests_mock.mock() as m:
         m.post(self.url,
                text='success',
                request_headers={'x-ha-access': 'password'})
         assis = ExecuteHomeAssistant(
             'key', self.default_data(extra_data={'access': 'password'}))
         assis.execute()
         self.assertTrue(m.called_once)
Esempio n. 2
0
 def test_execute_with_access_token(self):
     with requests_mock.mock() as m:
         m.post(self.url,
                text='success',
                request_headers={'Authorization': 'Bearer abcde12345'})
         assis = ExecuteHomeAssistant(
             'key',
             self.default_data(extra_data={'access_token': 'abcde12345'}))
         assis.execute()
         self.assertTrue(m.called_once)
Esempio n. 3
0
 def test_execute(self):
     with requests_mock.mock() as m:
         m.post(self.url, text='success')
         assis = ExecuteHomeAssistant('key', self.default_data())
         assis.execute()
         self.assertTrue(m.called_once)
Esempio n. 4
0
 def test_full_address(self):
     assis = ExecuteHomeAssistant(
         'key', self.default_data('https://localhost:7123'))
     self.assertIn('url', assis.data)
     self.assertEqual(assis.data['url'],
                      'https://localhost:7123' + self.path)
Esempio n. 5
0
 def test_include_address_protocol(self):
     assis = ExecuteHomeAssistant('key',
                                  self.default_data('https://localhost'))
     self.assertIn('url', assis.data)
     self.assertEqual(assis.data['url'],
                      'https://localhost:8123' + self.path)
Esempio n. 6
0
 def test_only_address(self):
     assis = ExecuteHomeAssistant('key', self.default_data())
     self.assertIn('url', assis.data)
     self.assertEqual(assis.data['url'], self.url)
Esempio n. 7
0
 def test_no_event(self):
     with self.assertRaises(InvalidConfig):
         ExecuteHomeAssistant('key', self.default_data(event=''))