Skip to content

Commit

Permalink
rearrange tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tawakalt committed Apr 13, 2023
1 parent 1d99564 commit ccd24b4
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions tests/shared/core/test_slot_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,19 @@ def test_slot_mappings_check_mapping_validity_from_intent():
)


def test_slot_mappings_check_mapping_validity_valid_intent_list():
@pytest.mark.parametrize(
"intent, expected",
[
(["goodbye", "mood_great", "greet"], True),
([], True),
("", True),
({}, True),
("null", True),
],
)
def test_slot_mappings_check_mapping_validity_valid_intent_list(
intent: Text, expected: bool
):
slot_name = "mood"
domain = Domain.from_yaml(
f"""
Expand All @@ -179,45 +191,35 @@ def test_slot_mappings_check_mapping_validity_valid_intent_list():
- goodbye
- mood_great
- mood_unhappy
slots:
{slot_name}:
type: any
influence_conversation: false
mappings:
- type: from_intent
value: "testing 123"
intent:
- goodbye
- mood_great
- greet
intent: {intent}
forms:
test_form:
required_slots:
- test_slot
"""
)
mappings_for_slot = domain.as_dict().get("slots").get(slot_name).get("mappings")
assert SlotMapping.check_mapping_validity(
slot_name=slot_name,
mapping_type=SlotMappingType.FROM_INTENT,
mapping=mappings_for_slot[0],
domain=domain,
assert (
SlotMapping.check_mapping_validity(
slot_name=slot_name,
mapping_type=SlotMappingType.FROM_INTENT,
mapping=mappings_for_slot[0],
domain=domain,
)
is expected
)


@pytest.mark.parametrize(
"intent, expected",
[
(["a", "b", "c"], False),
([], True),
("", True),
({}, True),
("null", True),
],
)
def test_slot_mappings_check_mapping_validity_invalid_intent_list(
intent: Text, expected: bool
):
def test_slot_mappings_check_mapping_validity_invalid_intent_list():
slot_name = "mood"
domain = Domain.from_yaml(
f"""
Expand All @@ -227,29 +229,27 @@ def test_slot_mappings_check_mapping_validity_invalid_intent_list(
- goodbye
- mood_great
- mood_unhappy
slots:
{slot_name}:
type: any
influence_conversation: false
mappings:
- type: from_intent
value: "testing 123"
intent: {intent}
intent:
- aaaa
- bbbb
- cccc
forms:
test_form:
required_slots:
- test_slot
"""
)
mappings_for_slot = domain.as_dict().get("slots").get(slot_name).get("mappings")
assert (
SlotMapping.check_mapping_validity(
slot_name=slot_name,
mapping_type=SlotMappingType.FROM_INTENT,
mapping=mappings_for_slot[0],
domain=domain,
)
is expected
assert not SlotMapping.check_mapping_validity(
slot_name=slot_name,
mapping_type=SlotMappingType.FROM_INTENT,
mapping=mappings_for_slot[0],
domain=domain,
)

0 comments on commit ccd24b4

Please sign in to comment.