Skip to content

Commit 758e08f

Browse files
ehdsouzagermanattanasio
authored andcommitted
changing to 407 coz http.client.responses.keys() doesnt have 429
1 parent a34320a commit 758e08f

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

test/test_conversation_v1.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,42 @@ def test_create_counterexample():
5353
def test_rate_limit_exceeded():
5454
endpoint = '/v1/workspaces/{0}/counterexamples'.format('boguswid')
5555
url = '{0}{1}'.format(base_url, endpoint)
56-
error_msg = {'Code': '429', 'Error: ': u'Rate Limit exceeded'}
56+
error_code = "'code': '407'"
57+
error_msg = 'Rate limit exceeded'
5758
responses.add(
5859
responses.POST,
5960
url,
60-
body='Rate Limit exceeded',
61-
status=429)
61+
body='Rate limit exceeded',
62+
status=407,
63+
content_type='application/json')
6264
service = watson_developer_cloud.ConversationV1(
6365
username='username', password='password', version='2017-02-03')
6466
try:
6567
counterexample = service.create_counterexample(
6668
workspace_id='boguswid', text='I want financial advice today.')
6769
except WatsonException as ex:
6870
assert len(responses.calls) == 1
69-
assert ex.message == error_msg
71+
assert error_code in str(ex)
72+
assert error_msg in str(ex)
73+
74+
@responses.activate
75+
def test_unknown_error():
76+
endpoint = '/v1/workspaces/{0}/counterexamples'.format('boguswid')
77+
url = '{0}{1}'.format(base_url, endpoint)
78+
error_msg = 'Unknown error'
79+
responses.add(
80+
responses.POST,
81+
url,
82+
status=407,
83+
content_type='application/json')
84+
service = watson_developer_cloud.ConversationV1(
85+
username='username', password='password', version='2017-02-03')
86+
try:
87+
service.create_counterexample(
88+
workspace_id='boguswid', text='I want financial advice today.')
89+
except WatsonException as ex:
90+
assert len(responses.calls) == 1
91+
assert error_msg in str(ex)
7092

7193
@responses.activate
7294
def test_delete_counterexample():

0 commit comments

Comments
 (0)