X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=tests%2Fgoogle_assistant_test.py;h=a16259455a8be80840a346626f09932728eb16c5;hb=532df2c5b57c7517dfb3dddd8c1358fbadf8baf3;hp=7699337f257a5072205ebeaeddfce940e230eda5;hpb=43635064329197b2f9e822d15e7315ac59141207;p=python_utils.git diff --git a/tests/google_assistant_test.py b/tests/google_assistant_test.py index 7699337..a162594 100755 --- a/tests/google_assistant_test.py +++ b/tests/google_assistant_test.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +# © Copyright 2021-2022, Scott Gasch + +"""google_assistant unittest.""" + import unittest from unittest.mock import MagicMock, patch @@ -8,8 +12,7 @@ import unittest_utils # Needed for --unittests_ignore_perf flag class TestGoogleAssistant(unittest.TestCase): - def test_basic_functionality(self): - + def test_failure_case(self): with patch('requests.post') as mock: response = MagicMock() response.status_code = 404 @@ -20,6 +23,16 @@ class TestGoogleAssistant(unittest.TestCase): self.assertEqual('', ret.audio_transcription) self.assertEqual('', ret.audio_url) + def test_success_case(self): + with patch('requests.post') as mock: + response = MagicMock() + response.status_code = 200 + json = {'response': 'LGTM', 'audio': '', 'success': True} + response.json = MagicMock(return_value=json) + mock.return_value = response + ret = google_assistant.ask_google('Is this thing working?', recognize_speech=False) + self.assertTrue(ret.success) + if __name__ == '__main__': unittest.main()