def test_swap_intent_with2(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # make sure intent not swapped after another action than the one specified in the rule parse_data = {"intent": {"name": "whatever", "confidence": 1.0}} Rules._swap_intent(parse_data, None, swap_rules.rules[1]) assert parse_data["intent"]["name"] == "whatever"
def test_swap_intent_with1(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # make sure intent swapped parse_data = {"intent": {"name": "chitchat.i_am_angry", "confidence": 1.0}} Rules._swap_intent(parse_data, None, swap_rules.rules[1]) assert parse_data["intent"]["name"] == "request.handover"
def test_swap_intent_after1(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # make sure intent swapped parse_data = {"intent": {"name": "whatever", "confidence": 1.0}} Rules._swap_intent(parse_data, "utter_something", swap_rules.rules[0]) assert parse_data["intent"]["name"] == "intent_something"
def test_swap_intent_with3(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # make sure intent is swapped and entity is added parse_data = {"intent": {"name": "chitchat.bye", "confidence": 1.0}} Rules._swap_intent(parse_data, None, swap_rules.rules[2]) assert parse_data["intent"]["name"] == "chitchat" assert parse_data["entities"][0]["entity"] == "intent" assert parse_data["entities"][0]["value"] == "chitchat.bye"
def test_swap_intent_with4(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # just checking regex is ok parse_data = { "intent": { "name": "chitchat.this_is_frustrating", "confidence": 1.0 } } Rules._swap_intent(parse_data, None, swap_rules.rules[2]) assert parse_data["intent"]["name"] == "chitchat.this_is_frustrating"
def test_swap_intent_after2(): swap_rules = InputValidator( InputValidator._load_yaml(VALIDATOR_RULES_YAML)['intent_substitution']) # make sure intent is not swapped when in unless list parse_data = { "intent": { "name": "chitchat.this_is_frustrating", "confidence": 1.0 } } Rules._swap_intent(parse_data, "utter_something", swap_rules.rules[0]) assert parse_data["intent"]["name"] == "chitchat.this_is_frustrating"