Skip to content

Commit

Permalink
fix bug: empty list value (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: yeghia <ygarinyan@bluip.com>
  • Loading branch information
yeghiakoronian and yeghia committed Dec 9, 2023
1 parent 71b6482 commit 1ec5c1f
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dialogflow_log_parser/es/logic/hocon_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def get_field_value(self, field_value_hocon: ConfigTree):
fieldの中身をConfigTreeに変換する
'''
result = ''
if field_value_hocon.get('list_value', False):
if field_value_hocon.get('list_value', False) is not False:
list_value = []
for value in field_value_hocon['list_value']['values']:
for value in field_value_hocon['list_value'].get('values', []):
list_value.append(self.get_field_value(value))
else:
return list_value
Expand Down
57 changes: 57 additions & 0 deletions test/es/data/destination/8_empty_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"id": "response_id",
"lang": "ja",
"session_id": "dfMessenger-session-id",
"timestamp": "2000-01-01T01:00:21.720007Z",
"result": {
"source": "agent",
"resolved_query": "WELCOME",
"action": "input.welcome",
"score": 1.0,
"parameters": [
{
"list-parameter": [
"list_paremeter_value"
]
},
{
"list-noparameter": []
}
],
"contexts": [
{
"name": "yes-or-no",
"lifespan": 2147483647,
"parameters": [
{
"list-parameter": [
"list_paremeter_value"
]
}
]
}
],
"metadata": {
"intent_id": "intent_id",
"intent_name": "Intent name",
"webhook_used": "false",
"webhook_for_slot_filling_used": "false",
"is_fallback_intent": "false"
},
"fulfillment": {
"speech": "Can you say that again?",
"messages": [
{
"payload": {
"activities": []
},
"type": 4.0
}
]
}
},
"status": {
"code": 200,
"error_type": "success"
}
}
74 changes: 74 additions & 0 deletions test/es/data/response/8_empty_list.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Dialogflow Response :
id: "response_id"
lang: "ja"
session_id: "dfMessenger-session-id"
timestamp: "2000-01-01T01:00:21.720007Z"
result {
source: "agent"
resolved_query: "WELCOME"
action: "input.welcome"
score: 1.0
parameters {
fields {
key: "list-parameter"
value {
list_value {
values {
string_value: "list_paremeter_value"
}
}
}
}
fields {
key: "list-noparameter"
value {
list_value {
}
}
}
}
contexts {
name: "yes-or-no"
lifespan: 2147483647
parameters {
fields {
key: "list-parameter"
value {
list_value {
values {
string_value: "list_paremeter_value"
}
}
}
}
}
}
metadata {
intent_id: "intent_id"
intent_name: "Intent name"
webhook_used: "false"
webhook_for_slot_filling_used: "false"
is_fallback_intent: "false"
}
fulfillment {
speech: "Can you say that again?"
messages {
payload {
fields {
key: "activities"
value {
list_value {
}
}
}
}
type {
number_value: 4.0
}
}
}
}
status {
code: 200
error_type: "success"
}
9 changes: 9 additions & 0 deletions test/es/test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,12 @@ def test_data_key(self):
dest_dict = json.loads(dest)

self.assertDictEqual(response_dict, dest_dict)

def test_empty_list(self):
response = self.get_conf_file('8_empty_list.conf')
dest = self.get_dest_file('8_empty_list.json')

response_dict = response_to_dict(response)
dest_dict = json.loads(dest)

self.assertDictEqual(response_dict, dest_dict)

0 comments on commit 1ec5c1f

Please sign in to comment.