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