8000 Fixed retry prompting in NumberPrompt by adding await (#302) · sherlock666/botbuilder-python@6c15775 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c15775

Browse files
authored
Fixed retry prompting in NumberPrompt by adding await (microsoft#302)
* Fixed retry prompting in NumberPrompt by adding await * ran black on libraries
1 parent dcc99c2 commit 6c15775

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def on_prompt(
4040
raise TypeError("NumberPrompt.on_prompt(): options cannot be None.")
4141

4242
if is_retry and options.retry_prompt is not None:
43-
turn_context.send_activity(options.retry_prompt)
43+
await turn_context.send_activity(options.retry_prompt)
4444
elif options.prompt is not None:
4545
await turn_context.send_activity(options.prompt)
4646

libraries/botbuilder-dialogs/tests/test_number_prompt.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ async def exec_test(turn_context: TurnContext) -> None:
125125
test_flow4 = await test_flow3.send("Give me twenty meters of cable")
126126
await test_flow4.assert_reply("You asked me for '20' meters of cable.")
127127

128-
# TODO: retry_prompt in NumberPrompt appears to be broken
129-
# It when NumberPrompt fails to receive a number, it retries, prompting
130-
# with the prompt and not retry prompt in options
131128
async def test_number_prompt_retry(self):
132129
async def exec_test(turn_context: TurnContext) -> None:
133130
dialog_context: DialogContext = await dialogs.create_context(turn_context)
@@ -161,14 +158,11 @@ async def exec_test(turn_context: TurnContext) -> None:
161158
dialogs.add(number_prompt)
162159

163160
step1 = await adapter.send("hello")
164-
await step1.assert_reply("Enter a number.")
165-
# TODO: something is breaking in the validators or retry prompt
166-
# where it does not accept the 2nd answer after reprompting the user
167-
# for another value
168-
# step3 = await step2.send("hello")
169-
# step4 = await step3.assert_reply("You must enter a number.")
170-
# step5 = await step4.send("64")
171-
# await step5.assert_reply("Bot received the number '64'.")
161+
step2 = await step1.assert_reply("Enter a number.")
162+
step3 = await step2.send("hello")
163+
step4 = await step3.assert_reply("You must enter a number.")
164+
step5 = await step4.send("64")
165+
await step5.assert_reply("Bot received the number '64'.")
172166

173167
async def test_number_uses_locale_specified_in_constructor(self):
174168
# Create new ConversationState with MemoryStorage and register the state as middleware.
@@ -272,13 +266,12 @@ async def validator(prompt_context: PromptValidatorContext):
272266

273267
step1 = await adapter.send("hello")
274268
step2 = await step1.assert_reply("Enter a number.")
275-
await step2.send("150")
276-
# TODO: something is breaking in the validators or retry prompt
277-
# where it does not accept the 2nd answer after reprompting the user
278-
# for another value
279-
# step4 = await step3.assert_reply("You must enter a positive number less than 100.")
280-
# step5 = await step4.send("64")
281-
# await step5.assert_reply("Bot received the number '64'.")
269+
step3 = await step2.send("150")
270+
step4 = await step3.assert_reply(
271+
"You must enter a positive number less than 100."
272+
)
273+
step5 = await step4.send("64")
274+
await step5.assert_reply("Bot received the number '64'.")
282275

283276
async def test_float_number_prompt(self):
284277
async def exec_test(turn_context: TurnContext) -> None:

0 commit comments

Comments
 (0)
0