|
17 | 17 | HTTPOk, |
18 | 18 | ) |
19 | 19 | from common_library.error_codes import ErrorCodeStr, create_error_code |
20 | | -from servicelib.aiohttp.rest_responses import create_http_error, exception_to_response |
| 20 | +from servicelib.aiohttp.rest_responses import ( |
| 21 | + MAX_STATUS_MESSAGE_LENGTH, |
| 22 | + create_http_error, |
| 23 | + exception_to_response, |
| 24 | +) |
21 | 25 | from servicelib.aiohttp.web_exceptions_extension import ( |
22 | 26 | _STATUS_CODE_TO_HTTP_ERRORS, |
23 | 27 | get_http_error_class_or_none, |
@@ -136,10 +140,13 @@ def tests_exception_to_response( |
136 | 140 | "Message\nwith\nnewlines", |
137 | 141 | "Message with newlines", |
138 | 142 | ), # Newlines are replaced with spaces |
139 | | - ("A" * 100, "A" * 47 + "..."), # Long message gets truncated with ellipsis |
140 | 143 | ( |
141 | | - "Line1\nLine2\nLine3" + "X" * 100, |
142 | | - "Line1 Line2 Line3" + "X" * 30 + "...", |
| 144 | + "A" * (MAX_STATUS_MESSAGE_LENGTH + 1), |
| 145 | + "A" * (MAX_STATUS_MESSAGE_LENGTH - 3) + "...", |
| 146 | + ), # Long message gets truncated with ellipsis |
| 147 | + ( |
| 148 | + "Line1\nLine2\nLine3" + "X" * (MAX_STATUS_MESSAGE_LENGTH + 1), |
| 149 | + "Line1 Line2 Line3" + "X" * (MAX_STATUS_MESSAGE_LENGTH - 20) + "...", |
143 | 150 | ), # Combined case: newlines and truncation with ellipsis |
144 | 151 | ], |
145 | 152 | ids=[ |
|
0 commit comments