コード例 #1
0
def test_set_category_intent_handler_slot_without_value():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "SetTodCategory",
                "slots": {
                    "Category": {
                        "name": "Category"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "I'm not sure of which category you want to play. " \
                                                           "Please try again."
コード例 #2
0
def test_set_category_intent_handler():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "SetTodCategory",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "We'll now play with questions from the category family " \
                                                           "game night. You can ask me a truth or a dare question " \
                                                           "by saying, give me a truth question, or give me a dare."
コード例 #3
0
def test_set_category_intent_handler():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "SetTodCategory",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "We'll now play with questions from the category family " \
                                                           "game night. You can ask me a truth or a dare question " \
                                                           "by saying, give me a truth question, or give me a dare."
コード例 #4
0
def test_get_categories_intent_handler(get_all_categories):
    category1 = "category1"
    category2 = "category2"
    category3 = "category3"
    get_all_categories.return_value = [(category1,), (category2,), (category3,)]
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTodCategories",
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == (
        "The available categories are: " + category1 + ". " + category2 + ". " + category3 + ". Please tell me the "
                                                                                             "category you want to "
                                                                                             "play by saying, play "
                                                                                             "category kids, for "
                                                                                             "example.")
コード例 #5
0
def test_unknown_intent():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "UnknownIntent",
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)

    assert response['response']['outputSpeech'][
        'text'] == voice_interface.DEFAULT_SPEECH
コード例 #6
0
def test_unknown_intent():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "UnknownIntent",
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)

    assert response['response']['outputSpeech']['text'] == voice_interface.DEFAULT_SPEECH
コード例 #7
0
def test_set_category_intent_handler_slot_without_value():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "SetTodCategory",
                "slots": {
                    "Category": {
                        "name": "Category"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "I'm not sure of which category you want to play. " \
                                                           "Please try again."
コード例 #8
0
def test_get_truth_or_dare_question_with_session_attributes(
        get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "truth question 1?", "truth", 6),
        (2, "truth question 2?", "truth", 6),
        (3, "truth question 3?", "truth", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    },
                    "Type": {
                        "name": "Type",
                        "value": "truth"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {
                'category': 'family game night',
                'dare_index': 1,
                'truth_index': 2
            },
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "truth question 3? Now tell me, do you want a Truth " \
                                                           "or a Dare?"
    assert response['sessionAttributes'] == {
        'category': 'family game night',
        'dare_index': 1,
        'truth_index': 3
    }
コード例 #9
0
def test_get_truth_or_dare_question_category_completed(
        get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "truth question 1", "truth", 6),
        (2, "truth question 2", "truth", 6),
        (3, "truth question 3", "truth", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    },
                    "Type": {
                        "name": "Type",
                        "value": "truth"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {
                'category': 'family game night',
                'truth_index': 3
            },
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "Congratulations! You completed the category family " \
                                                           "game night. " \
                                                           "If you want to hear the list of categories again, " \
                                                           "say: give me the categories."
    assert response['sessionAttributes'] == {}
コード例 #10
0
def test_get_truth_or_dare_question_category_completed(get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "truth question 1", "truth", 6),
        (2, "truth question 2", "truth", 6),
        (3, "truth question 3", "truth", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    },
                    "Type": {
                        "name": "Type",
                        "value": "truth"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {
                'category': 'family game night',
                'truth_index': 3
            },
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "Congratulations! You completed the category family " \
                                                           "game night. " \
                                                           "If you want to hear the list of categories again, " \
                                                           "say: give me the categories."
    assert response['sessionAttributes'] == {}
コード例 #11
0
def test_get_truth_or_dare_question_with_session_attributes(get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "truth question 1?", "truth", 6),
        (2, "truth question 2?", "truth", 6),
        (3, "truth question 3?", "truth", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    },
                    "Type": {
                        "name": "Type",
                        "value": "truth"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {
                'category': 'family game night',
                'dare_index': 1,
                'truth_index': 2
            },
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "truth question 3? Now tell me, do you want a Truth " \
                                                           "or a Dare?"
    assert response['sessionAttributes'] == {'category': 'family game night', 'dare_index': 1, 'truth_index': 3}
コード例 #12
0
def test_default_handler():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "requestId": "EdwRequestId.1234",
            "timestamp": "2016-05-27T05:55:21Z",
            "type": "UnknownRequest"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == voice_interface.DEFAULT_SPEECH
コード例 #13
0
def test_default_handler():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "requestId": "EdwRequestId.1234",
            "timestamp": "2016-05-27T05:55:21Z",
            "type": "UnknownRequest"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech'][
        'text'] == voice_interface.DEFAULT_SPEECH
コード例 #14
0
def test_get_truth_or_dare_question_without_type(
        get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "dare question 1", "dare", 6),
        (2, "dare question 2", "dare", 6),
        (3, "dare question 3", "dare", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {},
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "I'm not sure if you asked for a truth or a dare. " \
                                                           "Please try again."
コード例 #15
0
def test_get_truth_or_dare_question_without_type(get_questions_of_type_and_category):
    get_questions_of_type_and_category.return_value = [
        (1, "dare question 1", "dare", 6),
        (2, "dare question 2", "dare", 6),
        (3, "dare question 3", "dare", 6),
    ]
    request = {
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTruthOrDare",
                "slots": {
                    "Category": {
                        "name": "Category",
                        "value": "family game night"
                    }
                }
            },
            "locale": "en-US"
        },
        "version": "1.0",
        "session": {
            "new": False,
            "sessionId": "amzn1.echo-api.session.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "attributes": {},
            "user": {
                "userId": "amzn1.account.1234"
            }
        }
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == "I'm not sure if you asked for a truth or a dare. " \
                                                           "Please try again."
コード例 #16
0
def test_launch_request_route_to_welcome():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": True
        },
        "request": {
            "requestId": "EdwRequestId.1234",
            "timestamp": "2016-05-27T05:55:21Z",
            "type": "LaunchRequest"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)

    assert response['response']['outputSpeech'][
        'text'] == voice_interface.WELCOME_SPEECH
コード例 #17
0
def test_launch_request_route_to_welcome():
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": True
        },
        "request": {
            "requestId": "EdwRequestId.1234",
            "timestamp": "2016-05-27T05:55:21Z",
            "type": "LaunchRequest"

        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)

    assert response['response']['outputSpeech']['text'] == voice_interface.WELCOME_SPEECH
コード例 #18
0
def test_get_categories_intent_handler(get_all_categories):
    category1 = "category1"
    category2 = "category2"
    category3 = "category3"
    get_all_categories.return_value = [(category1, ), (category2, ),
                                       (category3, )]
    request = {
        "session": {
            "sessionId": "SessionId.1234",
            "application": {
                "applicationId": voice_interface.ALEXA_SKILL_ID
            },
            "user": {
                "userId": "amzn1.ask.account.1234"
            },
            "new": False
        },
        "request": {
            "type": "IntentRequest",
            "requestId": "1234",
            "timestamp": "2016-05-22T18:36:12Z",
            "intent": {
                "name": "GetTodCategories",
            },
            "locale": "en-US"
        },
        "version": "1.0"
    }
    response = voice_interface.lambda_handler(request)
    assert response['response']['outputSpeech']['text'] == (
        "The available categories are: " + category1 + ". " + category2 +
        ". " + category3 + ". Please tell me the "
        "category you want to "
        "play by saying, play "
        "category kids, for "
        "example.")