Skip to content

Commit f911e55

Browse files
authored
improvement for systemic errors (#122)
* added a better message when errors are not caused by Algorithms * make failure test compliant with other testcase components
1 parent 7fd688d commit f911e55

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Algorithmia/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ def raiseAlgoApiError(result):
4747
stacktrace = None
4848
return AlgorithmException(message=message, stack_trace=stacktrace, error_type=err_type)
4949
else:
50-
return Exception(result)
50+
return Exception("Non-Algorithm related Failure: " + str(result))

Test/algo_failure_test.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,19 @@
1414
from Test.api import app
1515

1616

17-
def start_webserver():
18-
uvicorn.run(app, host="127.0.0.1", port=8080, log_level="debug")
19-
20-
2117
class AlgoTest(unittest.TestCase):
2218
error_500 = Response()
2319
error_500.status_code = 500
20+
error_message = "Non-Algorithm related Failure: " + str(error_500)
2421

25-
def setUp(self):
26-
self.client = Algorithmia.client(api_address="http://localhost:8080")
27-
self.uvi_p = Process(target=start_webserver)
28-
self.uvi_p.start()
29-
time.sleep(1)
30-
31-
def tearDown(self):
32-
self.uvi_p.terminate()
22+
@classmethod
23+
def setUpClass(cls):
24+
cls.client = Algorithmia.client(api_address="http://localhost:8080", api_key="simabcd123")
3325

3426
def test_throw_500_error_HTTP_response_on_algo_request(self):
3527
try:
3628
result = self.client.algo('util/500').pipe(bytearray('foo', 'utf-8'))
3729
except Exception as e:
3830
result = e
3931
pass
40-
self.assertEqual(str(self.error_500), str(result))
32+
self.assertEqual(str(self.error_message), str(result))

0 commit comments

Comments
 (0)