Skip to content

Commit

Permalink
feat(assistantv1): New param new_disambiguation_opt_out in `update…
Browse files Browse the repository at this point in the history
…_dialog_node() `
  • Loading branch information
ehdsouza committed Nov 20, 2019
1 parent e21caff commit 6e52e07
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
21 changes: 18 additions & 3 deletions ibm_watson/assistant_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,7 @@ def update_dialog_node(self,
new_digress_out=None,
new_digress_out_slots=None,
new_user_label=None,
new_disambiguation_opt_out=None,
**kwargs):
"""
Update dialog node.
Expand Down Expand Up @@ -2627,6 +2628,8 @@ def update_dialog_node(self,
to top-level nodes while filling out slots.
:param str new_user_label: (optional) A label that can be displayed
externally to describe the purpose of the node to users.
:param bool new_disambiguation_opt_out: (optional) Whether the dialog node
should be excluded from disambiguation suggestions.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
Expand Down Expand Up @@ -2670,7 +2673,8 @@ def update_dialog_node(self,
'digress_in': new_digress_in,
'digress_out': new_digress_out,
'digress_out_slots': new_digress_out_slots,
'user_label': new_user_label
'user_label': new_user_label,
'disambiguation_opt_out': new_disambiguation_opt_out
}

url = '/v1/workspaces/{0}/dialog_nodes/{1}'.format(
Expand Down Expand Up @@ -3710,6 +3714,8 @@ class DialogNode():
top-level nodes while filling out slots.
:attr str user_label: (optional) A label that can be displayed externally to
describe the purpose of the node to users.
:attr bool disambiguation_opt_out: (optional) Whether the dialog node should be
excluded from disambiguation suggestions.
:attr bool disabled: (optional) For internal use only.
:attr datetime created: (optional) The timestamp for creation of the object.
:attr datetime updated: (optional) The timestamp for the most recent update to
Expand All @@ -3736,6 +3742,7 @@ def __init__(self,
digress_out=None,
digress_out_slots=None,
user_label=None,
disambiguation_opt_out=None,
disabled=None,
created=None,
updated=None):
Expand Down Expand Up @@ -3781,6 +3788,8 @@ def __init__(self,
top-level nodes while filling out slots.
:param str user_label: (optional) A label that can be displayed externally
to describe the purpose of the node to users.
:param bool disambiguation_opt_out: (optional) Whether the dialog node
should be excluded from disambiguation suggestions.
:param bool disabled: (optional) For internal use only.
:param datetime created: (optional) The timestamp for creation of the
object.
Expand All @@ -3805,6 +3814,7 @@ def __init__(self,
self.digress_out = digress_out
self.digress_out_slots = digress_out_slots
self.user_label = user_label
self.disambiguation_opt_out = disambiguation_opt_out
self.disabled = disabled
self.created = created
self.updated = updated
Expand All @@ -3817,8 +3827,8 @@ def _from_dict(cls, _dict):
'dialog_node', 'description', 'conditions', 'parent',
'previous_sibling', 'output', 'context', 'metadata', 'next_step',
'title', 'type', 'event_name', 'variable', 'actions', 'digress_in',
'digress_out', 'digress_out_slots', 'user_label', 'disabled',
'created', 'updated'
'digress_out', 'digress_out_slots', 'user_label',
'disambiguation_opt_out', 'disabled', 'created', 'updated'
]
bad_keys = set(_dict.keys()) - set(valid_keys)
if bad_keys:
Expand Down Expand Up @@ -3868,6 +3878,8 @@ def _from_dict(cls, _dict):
args['digress_out_slots'] = _dict.get('digress_out_slots')
if 'user_label' in _dict:
args['user_label'] = _dict.get('user_label')
if 'disambiguation_opt_out' in _dict:
args['disambiguation_opt_out'] = _dict.get('disambiguation_opt_out')
if 'disabled' in _dict:
args['disabled'] = _dict.get('disabled')
if 'created' in _dict:
Expand Down Expand Up @@ -3917,6 +3929,9 @@ def _to_dict(self):
_dict['digress_out_slots'] = self.digress_out_slots
if hasattr(self, 'user_label') and self.user_label is not None:
_dict['user_label'] = self.user_label
if hasattr(self, 'disambiguation_opt_out'
) and self.disambiguation_opt_out is not None:
_dict['disambiguation_opt_out'] = self.disambiguation_opt_out
if hasattr(self, 'disabled') and self.disabled is not None:
_dict['disabled'] = self.disabled
if hasattr(self, 'created') and self.created is not None:
Expand Down
18 changes: 14 additions & 4 deletions test/unit/test_assistant_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,13 @@ def test_dialog_nodes():
status=200,
content_type='application/json')

responses.add(
responses.POST,
"{0}/location-done?version=2017-02-03".format(url),
body='{ "application/json": { "dialog_node": "location-done" }}',
status=200,
content_type='application/json')

responses.add(
responses.POST,
"{0}?version=2017-02-03".format(url),
Expand Down Expand Up @@ -1518,16 +1525,19 @@ def test_dialog_nodes():
assistant.create_dialog_node('id', 'location-done', user_label='xxx', disambiguation_opt_out=False)
assert responses.calls[0].response.json()['application/json']['dialog_node'] == 'location-done'

assistant.update_dialog_node('id', 'location-done', user_label='xxx', new_disambiguation_opt_out=False)
assert responses.calls[1].response.json()['application/json']['dialog_node'] == 'location-done'

assistant.delete_dialog_node('id', 'location-done')
assert responses.calls[1].response.json() == {"description": "deleted successfully"}
assert responses.calls[2].response.json() == {"description": "deleted successfully"}

assistant.get_dialog_node('id', 'location-done')
assert responses.calls[2].response.json() == {"application/json": {"dialog_node": "location-atm"}}
assert responses.calls[3].response.json() == {"application/json": {"dialog_node": "location-atm"}}

assistant.list_dialog_nodes('id')
assert responses.calls[3].response.json() == {"application/json": {"dialog_node": "location-atm"}}
assert responses.calls[4].response.json() == {"application/json": {"dialog_node": "location-atm"}}

assert len(responses.calls) == 4
assert len(responses.calls) == 5

@responses.activate
def test_delete_user_data():
Expand Down

0 comments on commit 6e52e07

Please sign in to comment.