Skip to content

Commit

Permalink
add test for test_update_full_retrieval_intent
Browse files Browse the repository at this point in the history
  • Loading branch information
vcidst committed Jan 19, 2024
1 parent 3dcbadb commit acf376b
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/core/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
IS_EXTERNAL,
SESSION_START_METADATA_SLOT,
)
from rasa.shared.nlu.constants import (
INTENT,
INTENT_NAME_KEY,

Check failure on line 89 in tests/core/test_processor.py

View workflow job for this annotation

GitHub Actions / Code Quality

F811 Redefinition of unused `INTENT_NAME_KEY` from line 73
FULL_RETRIEVAL_INTENT_NAME_KEY,
)

import logging

Expand Down Expand Up @@ -1928,3 +1933,62 @@ async def test_run_anonymization_pipeline_mocked_pipeline(
await processor.run_anonymization_pipeline(tracker)

event_diff.assert_called_once()


async def test_update_full_retrieval_intent(
default_processor: MessageProcessor,
) -> None:
parse_data = {
"text": "I like sunny days in berlin",
"intent": {"name": "chitchat", "confidence": 0.9},
"entities": [],
"response_selector": {
{
"all_retrieval_intents": ["faq", "chitchat"],
"faq": {
"response": {
"responses": [{"text": "Our return policy lasts 30 days."}],
"confidence": 1.0,
"intent_response_key": "faq/what_is_return_policy",
"utter_action": "utter_faq/what_is_return_policy",
},
"ranking": [
{
"confidence": 1.0,
"intent_response_key": "faq/what_is_return_policy",
},
{
"confidence": 2.3378809862799945e-19,
"intent_response_key": "faq/how_can_i_track_my_order",
},
],
},
"chitchat": {
"response": {
"responses": [
{
"text": "I am not sure of the whole week but I can see the sun is out today."

Check failure on line 1970 in tests/core/test_processor.py

View workflow job for this annotation

GitHub Actions / Code Quality

E501 Line too long (109 > 88 characters)
},
],
"confidence": 1.0,
"intent_response_key": "chitchat/ask_weather",
"utter_action": "utter_chitchat/ask_weather",
},
"ranking": [
{
"confidence": 1.0,
"intent_response_key": "chitchat/ask_weather",
},
{"confidence": 0.0, "intent_response_key": "chitchat/ask_name"},
],
},
}
},
}

default_processor._update_full_retrieval_intent(parse_data)

assert parse_data[INTENT][INTENT_NAME_KEY] == "chitchat"
# assert that parse_data["intent"] has a key called response
assert FULL_RETRIEVAL_INTENT_NAME_KEY in parse_data[INTENT]
assert parse_data[INTENT][FULL_RETRIEVAL_INTENT_NAME_KEY] == "chitchat/ask_weather"

0 comments on commit acf376b

Please sign in to comment.