Skip to content

Commit

Permalink
Default Slots will not appear on UI and updated corresponding test ca…
Browse files Browse the repository at this point in the history
…ses (#1612)
  • Loading branch information
himanshugt16 authored Dec 2, 2024
1 parent f2f296b commit 9d1d50e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 3 additions & 1 deletion kairon/shared/data/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 9 additions & 2 deletions tests/integration_test/services_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"])


Expand Down
17 changes: 1 addition & 16 deletions tests/unit_test/data_processor/data_processor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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):
Expand Down

0 comments on commit 9d1d50e

Please sign in to comment.