4 from unittest.mock import MagicMock, patch
6 import google_assistant
7 import unittest_utils # Needed for --unittests_ignore_perf flag
10 class TestGoogleAssistant(unittest.TestCase):
11 def test_basic_functionality(self):
13 with patch('requests.post') as mock:
14 response = MagicMock()
15 response.status_code = 404
16 mock.return_value = response
17 ret = google_assistant.ask_google('What happens with a 404 response?')
18 self.assertFalse(ret.success)
19 self.assertTrue('failed; code 404' in ret.response)
20 self.assertEqual('', ret.audio_transcription)
21 self.assertEqual('', ret.audio_url)
24 if __name__ == '__main__':