|
20 | 20 |
|
21 | 21 | from ask_sdk_model import ( |
22 | 22 | IntentRequest, RequestEnvelope, Intent, SessionEndedRequest, Context) |
| 23 | +from ask_sdk_model.canfulfill import CanFulfillIntentRequest |
23 | 24 | from ask_sdk_core.utils import ( |
24 | | - is_intent_name, is_request_type, viewport) |
| 25 | + is_canfulfill_intent_name, is_intent_name, is_request_type, viewport) |
25 | 26 | from ask_sdk_core.handler_input import HandlerInput |
26 | 27 | from ask_sdk_core.exceptions import AskSdkException |
27 | 28 | from ask_sdk_model.interfaces.viewport import ViewportState, Shape |
28 | 29 |
|
29 | 30 |
|
| 31 | +def test_is_canfulfill_intent_name_match(): |
| 32 | + test_canfulfill_intent_name = "TestIntent" |
| 33 | + test_handler_input = HandlerInput( |
| 34 | + request_envelope=RequestEnvelope(request=CanFulfillIntentRequest( |
| 35 | + intent=Intent(name=test_canfulfill_intent_name)))) |
| 36 | + |
| 37 | + canfulfill_intent_name_wrapper = is_canfulfill_intent_name(test_canfulfill_intent_name) |
| 38 | + assert canfulfill_intent_name_wrapper( |
| 39 | + test_handler_input), "is_canfulfill_intent_name matcher didn't match with the " \ |
| 40 | + "correct intent name" |
| 41 | + |
| 42 | + |
| 43 | +def test_is_canfulfill_intent_name_not_match(): |
| 44 | + test_canfulfill_intent_name = "TestIntent" |
| 45 | + test_handler_input = HandlerInput( |
| 46 | + request_envelope=RequestEnvelope(request=CanFulfillIntentRequest( |
| 47 | + intent=Intent(name=test_canfulfill_intent_name)))) |
| 48 | + |
| 49 | + canfulfill_intent_name_wrapper = is_canfulfill_intent_name("TestIntent1") |
| 50 | + assert not canfulfill_intent_name_wrapper( |
| 51 | + test_handler_input), "is_canfulfill_intent_name matcher matched with the " \ |
| 52 | + "incorrect intent name" |
| 53 | + |
| 54 | + |
| 55 | +def test_is_canfulfill_intent_not_match_intent(): |
| 56 | + test_canfulfill_intent_name = "TestIntent" |
| 57 | + test_canfulfill_handler_input = HandlerInput( |
| 58 | + request_envelope=RequestEnvelope(request=CanFulfillIntentRequest( |
| 59 | + intent=Intent(name=test_canfulfill_intent_name)))) |
| 60 | + |
| 61 | + intent_name_wrapper = is_intent_name(test_canfulfill_intent_name) |
| 62 | + assert not intent_name_wrapper( |
| 63 | + test_canfulfill_handler_input), "is_intent_name matcher matched with the " \ |
| 64 | + "incorrect request type" |
| 65 | + |
| 66 | + |
| 67 | +def test_is_intent_not_match_canfulfill_intent(): |
| 68 | + test_intent_name = "TestIntent" |
| 69 | + test_handler_input = HandlerInput( |
| 70 | + request_envelope=RequestEnvelope(request=IntentRequest( |
| 71 | + intent=Intent(name=test_intent_name)))) |
| 72 | + |
| 73 | + canfulfill_intent_name_wrapper = is_canfulfill_intent_name(test_intent_name) |
| 74 | + assert not canfulfill_intent_name_wrapper( |
| 75 | + test_handler_input), "is_canfulfill_intent_name matcher matched with the " \ |
| 76 | + "incorrect request type" |
| 77 | + |
| 78 | + |
30 | 79 | def test_is_intent_name_match(): |
31 | 80 | test_intent_name = "TestIntent" |
32 | 81 | test_handler_input = HandlerInput( |
@@ -344,5 +393,3 @@ def test_viewport_map_to_unknown_for_no_viewport(self): |
344 | 393 | assert (viewport.get_viewport_profile(test_request_env) |
345 | 394 | is viewport.ViewportProfile.UNKNOWN_VIEWPORT_PROFILE), ( |
346 | 395 | "Viewport profile couldn't resolve UNKNOWN_VIEWPORT_PROFILE") |
347 | | - |
348 | | - |
|
0 commit comments