async def test_default_slot_value_if_unfeaturized_slot(): story = """ stories: - story: my story steps: - intent: greet - slot_was_set: - my_slot """ domain = Domain.from_dict({ "intents": ["greet"], "slots": { "my_slot": { "type": "any", "mappings": [{ "type": "from_text" }] } }, }) reader = YAMLStoryReader(domain) with pytest.warns(None) as warnings: events = reader.read_from_string(story)[0].events assert isinstance(events[-1], SlotSet) assert events[-1].value is None assert not warnings
def _get_faq_rule(rule_name: Text, intent: Text, action_name: Text) -> "StoryStep": faq_rule = f""" version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}" rules: - rule: {rule_name} steps: - intent: {intent} - action: {action_name} """ story_reader = YAMLStoryReader() return story_reader.read_from_string(faq_rule)[0]
async def test_default_slot_value_if_slots_referenced_by_name_only(domain_dict: Dict): story = """ stories: - story: my story steps: - intent: greet - slot_was_set: - my_slot """ reader = YAMLStoryReader(Domain.from_dict(domain_dict)) events = reader.read_from_string(story)[0].events assert isinstance(events[-1], SlotSet) assert events[-1].value
async def test_default_slot_value_if_no_domain(): story = """ stories: - story: my story steps: - intent: greet - slot_was_set: - my_slot """ reader = YAMLStoryReader() with pytest.warns(None) as warnings: events = reader.read_from_string(story)[0].events assert isinstance(events[-1], SlotSet) assert events[-1].value is None assert not warnings
async def test_default_slot_value_if_incompatible_slots_referenced_by_name_only( domain: Dict, ): story = """ stories: - story: my story steps: - intent: greet - slot_was_set: - my_slot """ reader = YAMLStoryReader(Domain.from_dict(domain)) with pytest.warns(UserWarning): events = reader.read_from_string(story)[0].events assert isinstance(events[-1], SlotSet) assert events[-1].value is None