You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/test_api.py
+36-1Lines changed: 36 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -161,7 +161,7 @@ def testFailedPut(self):
161
161
)
162
162
payload= {"Unit": "Test"}
163
163
withself.assertRaises(ApiException):
164
-
response=self.Api.put("/test/put/400", payload)
164
+
self.Api.put("/test/put/400", payload)
165
165
166
166
@responses.activate
167
167
deftestDelete(self):
@@ -194,6 +194,41 @@ def testFailedDelete(self):
194
194
withself.assertRaises(ApiException):
195
195
self.Api.delete("/test/delete/exception")
196
196
197
+
@responses.activate
198
+
deftestFailedApiException(self):
199
+
"""
200
+
Test all paths of ApiException
201
+
"""
202
+
# Test Exception with no error in response
203
+
response_dict= {}
204
+
responses.add(
205
+
responses.GET,
206
+
f"{Config.api_base_url()}/test/no/error",
207
+
json=response_dict,
208
+
status=500,
209
+
)
210
+
withself.assertRaises(ApiException):
211
+
self.Api.get("/test/no/error")
212
+
213
+
# Test an exception which has no json in response
214
+
responses.add(
215
+
responses.GET,
216
+
f"{Config.api_base_url()}/test/invalid/json",
217
+
body='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n',
0 commit comments