def test_help_intent(self):
        expect = {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Scissors cuts Paper, Paper covers Rock, Rock crushes Lizard, Lizard poisons Spock, "
                        "Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves "
                        "Spock, Spock vaporizes Rock, and, as it always has, Rock crushes Scissors.</speak>"
            },
            "shouldEndSession": False,
            "card": {
                "type": "Simple",
                "title": "Help",
                "content": "Scissors cuts Paper, Paper covers Rock, Rock crushes Lizard, Lizard poisons Spock, "
                           "Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves "
                           "Spock, Spock vaporizes Rock, and, as it always has, Rock crushes Scissors."
            },
            "reprompt": {
                "outputSpeech": {
                    "type": "SSML",
                    "ssml": "<speak>Please choose a shape and throw it, or say 'help me' one more time.</speak>"
                }
            }
        }

        response = lambda_handler(new_request('AMAZON.HelpIntent'), context)
        self.assertEqual(response['response'], expect)
Beispiel #2
0
def test_intent():
    request = new_request('MyIntent', {'SlotName': 'slot value'})
    response = handler(request, context)

    expected_response = 'Your intent was reached. My response is, "slot value".'
    assert expected_response in response['response']['outputSpeech']['ssml']
    assert expected_response in response['response']['reprompt'][
        'outputSpeech']['ssml']
    def test_throw(self):
        response = lambda_handler(new_request('ThrowIntent', {'SHAPE': 'lizard'}), context)

        self.assertEqual(response['response']['shouldEndSession'], False)
        self.assertEqual(response['response']['outputSpeech']['type'], 'SSML')
        self.assertEqual(response['response']['reprompt'],  {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Please choose a shape and throw it</speak>"
            }
        })

        self.__check_throw_response(response['response']['outputSpeech']['ssml'], 'lizard')
    def test_stop_intent(self):
        expect = {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Thank you for playing with me. Have a nice day!</speak>"
            },
            "shouldEndSession": True,
            "card": {
                "type": "Simple",
                "title": "Session Ended",
                "content": "Thank you for playing with me. Have a nice day!"
            }
        }

        response = lambda_handler(new_request('AMAZON.StopIntent'), context)
        self.assertEqual(response['response'], expect)
    def test_launch(self):
        expect = {
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak>Hi! And welcome to rock paper scissors lizard spock! Please choose a shape and throw "
                        "it.</speak>"
            },
            "shouldEndSession": False,
            "card": {
                "type": "Simple",
                "title": "Welcome",
                "content": "Hi! And welcome to rock paper scissors lizard spock! Please choose a shape and throw it."
            },
            "reprompt": {
                "outputSpeech": {
                    "type": "SSML",
                    "ssml": "<speak>Please choose a shape and throw it, or say 'help me' and I'll show you the game "
                            "rules.</speak>"
                }
            }
        }

        response = lambda_handler(new_request('LaunchRequest'), context)
        self.assertEqual(response['response'], expect)
 def test_session_end(self):
     response = lambda_handler(new_request('SessionEndedRequest'), context)
     self.assertEqual(response['response'], {})