|
18 | 18 |
|
19 | 19 | import unittest |
20 | 20 |
|
21 | | -from ask_sdk_model.interfaces.videoapp import LaunchDirective, VideoItem, Metadata |
22 | | -from ask_sdk_model.ui import SsmlOutputSpeech, Reprompt |
23 | | -from ask_sdk_model.interfaces.display import TextContent |
24 | | -from ask_sdk_model.interfaces.display import PlainText |
25 | | -from ask_sdk_model.interfaces.display import RichText |
26 | | -from ask_sdk_model.canfulfill import ( |
27 | | - CanFulfillIntent, CanFulfillIntentValues, CanFulfillSlot, |
28 | | - CanFulfillSlotValues, CanUnderstandSlotValues) |
| 21 | +from ask_sdk_core.response_helper import (PLAIN_TEXT_TYPE, RICH_TEXT_TYPE, |
| 22 | + ResponseFactory, |
| 23 | + get_plain_text_content, |
| 24 | + get_rich_text_content, |
| 25 | + get_text_content) |
| 26 | +from ask_sdk_model import directive |
| 27 | +from ask_sdk_model.canfulfill import (CanFulfillIntent, CanFulfillIntentValues, |
| 28 | + CanFulfillSlot, CanFulfillSlotValues, |
| 29 | + CanUnderstandSlotValues) |
| 30 | +from ask_sdk_model.interfaces.display import PlainText, RichText, TextContent |
| 31 | +from ask_sdk_model.interfaces.videoapp import (LaunchDirective, Metadata, |
| 32 | + VideoItem) |
| 33 | +from ask_sdk_model.response import Response |
| 34 | +from ask_sdk_model.ui import (Reprompt, SsmlOutputSpeech, output_speech, |
| 35 | + reprompt, ssml_output_speech) |
29 | 36 | from ask_sdk_model.ui.play_behavior import PlayBehavior |
30 | 37 |
|
31 | | -from ask_sdk_core.response_helper import ( |
32 | | - ResponseFactory, get_text_content, get_plain_text_content, |
33 | | - get_rich_text_content, PLAIN_TEXT_TYPE, RICH_TEXT_TYPE) |
34 | | - |
35 | 38 |
|
36 | 39 | class TestResponseFactory(unittest.TestCase): |
37 | 40 | def setUp(self): |
@@ -118,6 +121,25 @@ def test_add_two_directives(self): |
118 | 121 | "The add_directive method of ResponseFactory fails to add " |
119 | 122 | "multiple directives") |
120 | 123 |
|
| 124 | + def test_add_reprompt_directive(self): |
| 125 | + response_factory = self.response_factory.add_directive_to_reprompt(directive=None) |
| 126 | + |
| 127 | + assert len(response_factory.response.reprompt.directives) == 1, ( |
| 128 | + "The add_directive_to_reprompt method of ResponseFactory fails " |
| 129 | + "to add directive" |
| 130 | + ) |
| 131 | + |
| 132 | + def test_response_with_reprompt_directive(self): |
| 133 | + expected_response = Response( |
| 134 | + output_speech=SsmlOutputSpeech(ssml="<speak>Hello World</speak>"), |
| 135 | + reprompt=Reprompt(directives=['Alexa.Presentation.APLA.RenderDocument']), |
| 136 | + should_end_session=False) |
| 137 | + |
| 138 | + response_factory = self.response_factory.set_should_end_session(True).add_directive_to_reprompt( |
| 139 | + directive='Alexa.Presentation.APLA.RenderDocument').speak('Hello World') |
| 140 | + assert response_factory.response == expected_response, ( |
| 141 | + "The add_directive_to_reprompt method of ResponseFactory fails to add directive") |
| 142 | + |
121 | 143 | def test_add_video_app_launch_directive(self): |
122 | 144 | directive = LaunchDirective(video_item=VideoItem( |
123 | 145 | source=None, metadata=Metadata(title=None, subtitle=None))) |
|
0 commit comments