Skip to content

Commit

Permalink
Changes in checking empty intent mapping & new test
Browse files Browse the repository at this point in the history
- Replaced try/except statement with if/else when checking for empty intent mapping.
- Minor rewording on the exception message.
- Added a new test to check if the exception is correctly raised.
  • Loading branch information
Imod7 committed Mar 17, 2021
1 parent 3f22a32 commit f90ac7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rasa/shared/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ def _transform_intent_properties_for_internal_use(
"""
name, properties = list(intent.items())[0]

try:
if properties:
properties.setdefault(USE_ENTITIES_KEY, True)
except:
else:
raise InvalidDomain(
f"In the `domain.yml` file, the intent `{name}` cannot have value of"
f" `{type(properties)}`. This can happen if you add an intent with the"
Expand Down
8 changes: 4 additions & 4 deletions tests/shared/core/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,10 +1309,10 @@ def test_is_valid_domain_doesnt_raise_with_invalid_yaml(tmpdir: Path):


def test_domain_with_empty_intent_mapping():
# domain.yml with intent (intent_name) that has a `:` and nothing after it.
test_yaml = f"""
intents:
- intent_name:"""
# domain.yml with intent (intent_name) that has a `:` character
# and nothing after it.
test_yaml = """intents:
- intent_name:"""

with pytest.raises(InvalidDomain):
Domain.from_yaml(test_yaml).as_dict()

0 comments on commit f90ac7f

Please sign in to comment.