diff options
| author | Scott Gasch <[email protected]> | 2022-02-07 10:34:09 -0800 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-02-07 10:34:09 -0800 |
| commit | 43635064329197b2f9e822d15e7315ac59141207 (patch) | |
| tree | a52d2bd87c948797c98b0be7ffb0c9904398c91b /tests | |
| parent | d2357ff35e7752ae3eb6caa2813c35c17fea778b (diff) | |
Add a simple test to google_assistant code.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/google_assistant_test.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/google_assistant_test.py b/tests/google_assistant_test.py new file mode 100755 index 0000000..7699337 --- /dev/null +++ b/tests/google_assistant_test.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import unittest +from unittest.mock import MagicMock, patch + +import google_assistant +import unittest_utils # Needed for --unittests_ignore_perf flag + + +class TestGoogleAssistant(unittest.TestCase): + def test_basic_functionality(self): + + with patch('requests.post') as mock: + response = MagicMock() + response.status_code = 404 + mock.return_value = response + ret = google_assistant.ask_google('What happens with a 404 response?') + self.assertFalse(ret.success) + self.assertTrue('failed; code 404' in ret.response) + self.assertEqual('', ret.audio_transcription) + self.assertEqual('', ret.audio_url) + + +if __name__ == '__main__': + unittest.main() |
