Skip to content

Commit 9c7eeaf

Browse files
committed
- Updated test to use assertEqual for comparing HTTP status code of the exception.
- Replaced `assertTrue` with `assertIn` for more precise error message validation.
1 parent 9b7bfa0 commit 9c7eeaf

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

camunda/client/tests/test_engine_client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def test_start_process_server_error_raises_exception(self):
7878
with self.assertRaises(Exception) as exception_ctx:
7979
self.client.start_process(self.process_key, {"int_var": "1aa2345"}, self.tenant_id)
8080

81-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
82-
in str(exception_ctx.exception))
81+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
82+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
8383

8484
@responses.activate
8585
def test_get_process_instance_success(self):
@@ -136,8 +136,8 @@ def test_get_process_instance_server_error_raises_exception(self):
136136
variables=["intVar_XXX_1", "strVar_eq_hello"],
137137
tenant_ids=[self.tenant_id])
138138

139-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
140-
in str(exception_ctx.exception))
139+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
140+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
141141

142142
@patch('requests.post')
143143
def test_correlate_message_with_only_message_name(self, mock_post):

camunda/client/tests/test_engine_client_auth.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def test_auth_basic_start_process_server_error_raises_exception(self):
7878
with self.assertRaises(Exception) as exception_ctx:
7979
self.client.start_process(self.process_key, {"int_var": "1aa2345"}, self.tenant_id)
8080

81-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
82-
in str(exception_ctx.exception))
81+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
82+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
8383

8484
@responses.activate
8585
def test_auth_basic_get_process_instance_success(self):
@@ -136,8 +136,8 @@ def test_auth_basic_get_process_instance_server_error_raises_exception(self):
136136
variables=["intVar_XXX_1", "strVar_eq_hello"],
137137
tenant_ids=[self.tenant_id])
138138

139-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
140-
in str(exception_ctx.exception))
139+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
140+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
141141

142142
@patch('requests.post')
143143
def test_auth_basic_correlate_message_with_only_message_name(self, mock_post):

camunda/client/tests/test_engine_client_bearer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def test_auth_basic_start_process_server_error_raises_exception(self):
8181
with self.assertRaises(Exception) as exception_ctx:
8282
self.client.start_process(self.process_key, {"int_var": "1aa2345"}, self.tenant_id)
8383

84-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
85-
in str(exception_ctx.exception))
84+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
85+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
8686

8787
@responses.activate
8888
def test_auth_basic_get_process_instance_success(self):
@@ -139,8 +139,8 @@ def test_auth_basic_get_process_instance_server_error_raises_exception(self):
139139
variables=["intVar_XXX_1", "strVar_eq_hello"],
140140
tenant_ids=[self.tenant_id])
141141

142-
self.assertTrue(f"{HTTPStatus.INTERNAL_SERVER_ERROR} Server Error: Internal Server Error"
143-
in str(exception_ctx.exception))
142+
self.assertEqual(HTTPStatus.INTERNAL_SERVER_ERROR, exception_ctx.exception.response.status_code)
143+
self.assertIn("Server Error: Internal Server Error", str(exception_ctx.exception))
144144

145145
@patch('requests.post')
146146
def test_auth_basic_correlate_message_with_only_message_name(self, mock_post):

0 commit comments

Comments
 (0)