From 6e8e3458d9641394b8f061d55ba569a72e6a8493 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Mon, 7 Feb 2022 10:55:09 -0800 Subject: Adds unittest. --- tests/google_assistant_test.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/google_assistant_test.py b/tests/google_assistant_test.py index 7699337..857c1e4 100755 --- a/tests/google_assistant_test.py +++ b/tests/google_assistant_test.py @@ -8,8 +8,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 +19,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() -- cgit v1.3