diff --git a/kairon/shared/data/processor.py b/kairon/shared/data/processor.py index 9b85f2026..9c6820a7a 100644 --- a/kairon/shared/data/processor.py +++ b/kairon/shared/data/processor.py @@ -5264,7 +5264,9 @@ def get_existing_slots(bot: Text): :param status: active or inactive, default is active :return: list of slots """ - for slot in Slots.objects(bot=bot, status=True): + excluded_slots = list(KaironSystemSlots) + query = Q(bot=bot, status=True) & Q(name__nin=excluded_slots) + for slot in Slots.objects(query): slot = slot.to_mongo().to_dict() slot.pop("bot") slot.pop("user") diff --git a/tests/integration_test/services_test.py b/tests/integration_test/services_test.py index b490d210b..86d94605e 100644 --- a/tests/integration_test/services_test.py +++ b/tests/integration_test/services_test.py @@ -47,7 +47,7 @@ from kairon.shared.auth import Authentication from kairon.shared.cloud.utils import CloudUtility from kairon.shared.cognition.data_objects import CognitionSchema, CognitionData -from kairon.shared.constants import EventClass, ChannelTypes +from kairon.shared.constants import EventClass, ChannelTypes, KaironSystemSlots from kairon.shared.data.audit.data_objects import AuditLogData from kairon.shared.data.constant import ( UTTERANCE_TYPE, @@ -9699,10 +9699,17 @@ def test_get_slots(): headers={"Authorization": pytest.token_type + " " + pytest.access_token}, ) actual = response.json() + excluded_slots = list(KaironSystemSlots) + assert "data" in actual - assert len(actual["data"]) == 21 assert actual["success"] assert actual["error_code"] == 0 + + assert len(actual["data"]) == 21 - len(excluded_slots) + returned_slot_names = [slot["name"] for slot in actual["data"]] + for excluded_slot in excluded_slots: + assert excluded_slot not in returned_slot_names + assert Utility.check_empty_string(actual["message"]) diff --git a/tests/unit_test/data_processor/data_processor_test.py b/tests/unit_test/data_processor/data_processor_test.py index 452a9746c..7535b68d5 100644 --- a/tests/unit_test/data_processor/data_processor_test.py +++ b/tests/unit_test/data_processor/data_processor_test.py @@ -9348,20 +9348,6 @@ def test_get_slot(self): processor = MongoProcessor() slots = list(processor.get_existing_slots(bot)) expected = [ - {'name': 'kairon_action_response', 'type': 'any', 'influence_conversation': False, '_has_been_set': False}, - {'name': 'bot', 'type': 'any', 'initial_value': 'test', 'influence_conversation': False, - '_has_been_set': False}, - {'name': 'order', 'type': 'any', 'influence_conversation': False, '_has_been_set': False}, - {'name': 'payment', 'type': 'any', 'influence_conversation': False, '_has_been_set': False}, - {'name': 'flow_reply', 'type': 'any', 'influence_conversation': False, '_has_been_set': False}, - {'name': 'http_status_code', 'type': 'any', 'influence_conversation': False, '_has_been_set': False}, - {'name': 'image', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'audio', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'video', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'document', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'doc_url', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'longitude', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'latitude', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, {'name': 'date_time', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, {'name': 'category', 'type': 'text', 'influence_conversation': False, '_has_been_set': False}, {'name': 'file', 'type': 'text', 'influence_conversation': False, '_has_been_set': False}, @@ -9375,9 +9361,8 @@ def test_get_slot(self): {'name': 'age', 'type': 'float', 'max_value': 1.0, 'min_value': 0.0, 'influence_conversation': True, '_has_been_set': False}, {'name': 'occupation', 'type': 'text', 'influence_conversation': True, '_has_been_set': False}, - {'name': 'quick_reply', 'type': 'text', 'influence_conversation': True, '_has_been_set': False} ] - assert len(slots) == 24 + assert len(slots) == 10 assert not DeepDiff(slots, expected, ignore_order=True) def test_update_slot_add_value_intent_and_not_intent(self):