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

[ATO-1315] Flows yaml schema #12901

Merged
merged 30 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 rasa/shared/core/flows/flows_yaml_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"type": "object",
"patternProperties": {
"^[A-Za-z_][A-Za-z0-9_]*$": {
"type": ["string", "null"]
"type": ["string", "null", "boolean", "number"]
}
}
}
Expand Down
80 changes: 79 additions & 1 deletion tests/shared/utils/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,88 @@ def test_flow_validation_pass(flow_yaml: str) -> None:
"('next', 'END')])])])])]) is not valid under any of the given schemas."
),
),
( # action added to collect
"""flows:
test:
steps:
- collect: confirm_correct_card
action: utter_xyz
ask_before_filling: true
next: END""",
(
"([('collect', 'confirm_correct_card'), ('action', 'utter_xyz'),"
" ('ask_before_filling', True), ('next', 'END')]) is not"
" valid under any of the given schemas."
),
),
( # random addition to action
"""flows:
test:
steps:
- action: utter_xyz
random_xyz: true
next: END""",
(
"([('action', 'utter_xyz'), ('random_xyz', True),"
" ('next', 'END')]) is not valid under any of the given schemas."
),
),
( # random addition to collect
"""flows:
test:
steps:
- collect: confirm_correct_card
random_xyz: utter_xyz
ask_before_filling: true
next: END""",
(
"([('collect', 'confirm_correct_card'), ('random_xyz', 'utter_xyz'),"
" ('ask_before_filling', True), ('next', 'END')]) "
"is not valid under any of the given schemas."
),
),
(# random addition to flow definition
"""flows:
test:
random_xyz: True
steps:
- action: utter_xyz
next: END""",
"Additional properties are not allowed ('random_xyz' was unexpected)."
),
(
"""flows:
test:
steps:
- action: True
next: END""",
"True is not of type 'string'."),
( # next is a step
"""flows:
test:
steps:
- action: xyz
next:
- action: utter_xyz""",
(
"([('action', 'xyz'), ('next', [ordereddict([('action', 'utter_xyz')])])])"
" is not valid under any of the given schemas.")
),
( # next is a step
Urkem marked this conversation as resolved.
Show resolved Hide resolved
"""flows:
test:
steps:
- action: xyz
next:
- action: utter_xyz""",
(
"([('action', 'xyz'), ('next', [ordereddict([('action', 'utter_xyz')])])])"
" is not valid under any of the given schemas.")
),
],
)
def test_flow_validation_fail(flow_yaml: str, error_msg: str) -> None:
with pytest.raises((SchemaValidationError, TypeError)) as e:
with pytest.raises(SchemaValidationError) as e:
rasa.shared.utils.validation.validate_yaml_with_jsonschema(
flow_yaml, FLOWS_SCHEMA_FILE
)
Expand Down
Loading