From 4b18a596d318b3c8bf553487b01f4f3aa61e2373 Mon Sep 17 00:00:00 2001 From: 0x6f736f646f Date: Tue, 30 Jun 2020 23:25:49 +0300 Subject: [PATCH] Testing lights off --- tests/test_main.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 98b18bf..838a254 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -47,4 +47,44 @@ def test_publish_2(client): response = post_json(client, '/', example_response) assert response.status_code == 200 - assert json_of_response(response)['payload']['google']['richResponse']['items'][0]['simpleResponse']['textToSpeech'] == "The lights are on" \ No newline at end of file + assert json_of_response(response)['payload']['google']['richResponse']['items'][0]['simpleResponse']['textToSpeech'] == "The lights are on" + +def test_publish_3(client): + example_response = {'responseId': '3d######-####-####-####-############-######d2', + 'queryResult': {'queryText': 'Turn off lights', + 'parameters': {}, + 'allRequiredParamsPresent': True, + 'fulfillmentMessages': [ + {'text': {'text': ['']}} + ], 'outputContexts': [{ + 'name': 'projects/nodemcu-#####/agent/sessions/3c######-####-####-####-##########42/contexts/__system_counters__', + 'parameters': {'no-input': 0.0, 'no-match': 0.0}}], + 'intent': { + 'name': 'projects/nodemcu-#####/agent/intents/88######-####-####-####-##########b6', + 'displayName': 'Turn on or off led'}, 'intentDetectionConfidence': 1.0, + 'languageCode': 'en'}, 'originalDetectIntentRequest': {'payload': {}}, + 'session': 'projects/nodemcu-#####/agent/sessions/3c######-####-####-####-##########42'} + + response = post_json(client, '/', example_response) + assert response.status_code == 200 + assert json_of_response(response)['payload']['google']['richResponse']['items'][0]['simpleResponse']['textToSpeech'] == "The lights are off" + +def test_publish_4(client): + example_response = {'responseId': '3d######-####-####-####-############-######d2', + 'queryResult': {'queryText': 'lights', + 'parameters': {}, + 'allRequiredParamsPresent': True, + 'fulfillmentMessages': [ + {'text': {'text': ['']}} + ], 'outputContexts': [{ + 'name': 'projects/nodemcu-#####/agent/sessions/3c######-####-####-####-##########42/contexts/__system_counters__', + 'parameters': {'no-input': 0.0, 'no-match': 0.0}}], + 'intent': { + 'name': 'projects/nodemcu-#####/agent/intents/88######-####-####-####-##########b6', + 'displayName': 'Turn on or off led'}, 'intentDetectionConfidence': 1.0, + 'languageCode': 'en'}, 'originalDetectIntentRequest': {'payload': {}}, + 'session': 'projects/nodemcu-#####/agent/sessions/3c######-####-####-####-##########42'} + + response = post_json(client, '/', example_response) + assert response.status_code == 200 + assert json_of_response(response)['payload']['google']['richResponse']['items'][0]['simpleResponse']['textToSpeech'] == "Do you want to turn on or off the lights" \ No newline at end of file