Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces #923

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude = "((.eggs | .git | .mypy_cache | .pytest_cache | build | dist))"

[tool.poetry]
name = "rasa-sdk"
version = "3.4.0"
version = "3.5.0a1.dev1"
description = "Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants"
authors = [ "Rasa Technologies GmbH <[email protected]>",]
maintainers = [ "Tom Bocklisch <[email protected]>",]
Expand Down
2 changes: 1 addition & 1 deletion rasa_sdk/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def get_validation_events(
slots.pop(slot_name)
continue

method_name = f"validate_{slot_name.replace('-','_')}"
method_name = f"validate_{slot_name.replace('-','_').replace('.', '_')}"
validate_method = getattr(self, method_name, None)

if not validate_method:
Expand Down
2 changes: 1 addition & 1 deletion rasa_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# this file will automatically be changed,
# do not add anything but the version number here!
__version__ = "3.4.0"
__version__ = "3.5.0a1.dev1"
49 changes: 48 additions & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
)
from rasa_sdk.slots import SlotMapping


DEFAULT_DOMAIN = {
"slots": {
"some_other_slot": {
Expand Down Expand Up @@ -874,3 +873,51 @@ async def required_slots(
dispatcher = CollectingDispatcher()
events = await form.run(dispatcher=dispatcher, tracker=tracker, domain=domain)
assert events == expected_return_events


@pytest.mark.asyncio
async def test_form_validation_space_slot():
form_name = "some_form"

class TestFormValidationSpaceSlotAction(FormValidationAction):
def name(self) -> Text:
return form_name

def validate_space_slot(
self,
slot_value: Any,
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Dict[Text, Any]:
if slot_value == "correct_value":
return {
"space.slot": "validated_value",
}
return {
"space.slot": None,
}

form = TestFormValidationSpaceSlotAction()

# tracker with active form
tracker = Tracker(
"default",
{},
{},
[SlotSet("space.slot", "correct_value")],
False,
None,
{"name": form_name, "is_interrupted": False, "rejected": False},
"action_listen",
)

dispatcher = CollectingDispatcher()
events = await form.run(
dispatcher=dispatcher,
tracker=tracker,
domain={"forms": {form_name: {"required_slots": ["space.slot"]}}},
)
assert events == [
SlotSet("space.slot", "validated_value"),
]