|
18 | 18 | BASE_CONTACT_FIELDS_URL = ( |
19 | 19 | f"https://{GENERAL_HOST}/api/accounts/{ACCOUNT_ID}/contacts/fields" |
20 | 20 | ) |
| 21 | +VALIDATION_ERRORS_RESPONSE = { |
| 22 | + "errors": { |
| 23 | + "name": [["is too long (maximum is 80 characters)", "has already been taken"]], |
| 24 | + "merge_tag": [ |
| 25 | + ["is too long (maximum is 80 characters)", "has already been taken"] |
| 26 | + ], |
| 27 | + } |
| 28 | +} |
| 29 | +VALIDATION_ERRORS_MESSAGE = ( |
| 30 | + "name: ['is too long (maximum is 80 characters)', 'has already been taken']; " |
| 31 | + "merge_tag: ['is too long (maximum is 80 characters)', 'has already been taken']" |
| 32 | +) |
21 | 33 |
|
22 | 34 |
|
23 | 35 | @pytest.fixture |
@@ -62,6 +74,16 @@ class TestContactsApi: |
62 | 74 | conftest.FORBIDDEN_RESPONSE, |
63 | 75 | conftest.FORBIDDEN_ERROR_MESSAGE, |
64 | 76 | ), |
| 77 | + ( |
| 78 | + conftest.RATE_LIMIT_ERROR_STATUS_CODE, |
| 79 | + conftest.RATE_LIMIT_ERROR_RESPONSE, |
| 80 | + conftest.RATE_LIMIT_ERROR_MESSAGE, |
| 81 | + ), |
| 82 | + ( |
| 83 | + conftest.INTERNAL_SERVER_ERROR_STATUS_CODE, |
| 84 | + conftest.INTERNAL_SERVER_ERROR_RESPONSE, |
| 85 | + conftest.INTERNAL_SERVER_ERROR_MESSAGE, |
| 86 | + ), |
65 | 87 | ], |
66 | 88 | ) |
67 | 89 | @responses.activate |
@@ -117,6 +139,16 @@ def test_get_contact_fields_should_return_contact_field_list( |
117 | 139 | conftest.NOT_FOUND_RESPONSE, |
118 | 140 | conftest.NOT_FOUND_ERROR_MESSAGE, |
119 | 141 | ), |
| 142 | + ( |
| 143 | + conftest.RATE_LIMIT_ERROR_STATUS_CODE, |
| 144 | + conftest.RATE_LIMIT_ERROR_RESPONSE, |
| 145 | + conftest.RATE_LIMIT_ERROR_MESSAGE, |
| 146 | + ), |
| 147 | + ( |
| 148 | + conftest.INTERNAL_SERVER_ERROR_STATUS_CODE, |
| 149 | + conftest.INTERNAL_SERVER_ERROR_RESPONSE, |
| 150 | + conftest.INTERNAL_SERVER_ERROR_MESSAGE, |
| 151 | + ), |
120 | 152 | ], |
121 | 153 | ) |
122 | 154 | @responses.activate |
@@ -169,6 +201,21 @@ def test_get_contact_field_should_return_contact_field( |
169 | 201 | conftest.FORBIDDEN_RESPONSE, |
170 | 202 | conftest.FORBIDDEN_ERROR_MESSAGE, |
171 | 203 | ), |
| 204 | + ( |
| 205 | + conftest.RATE_LIMIT_ERROR_STATUS_CODE, |
| 206 | + conftest.RATE_LIMIT_ERROR_RESPONSE, |
| 207 | + conftest.RATE_LIMIT_ERROR_MESSAGE, |
| 208 | + ), |
| 209 | + ( |
| 210 | + conftest.INTERNAL_SERVER_ERROR_STATUS_CODE, |
| 211 | + conftest.INTERNAL_SERVER_ERROR_RESPONSE, |
| 212 | + conftest.INTERNAL_SERVER_ERROR_MESSAGE, |
| 213 | + ), |
| 214 | + ( |
| 215 | + conftest.VALIDATION_ERRORS_STATUS_CODE, |
| 216 | + VALIDATION_ERRORS_RESPONSE, |
| 217 | + VALIDATION_ERRORS_MESSAGE, |
| 218 | + ), |
172 | 219 | ], |
173 | 220 | ) |
174 | 221 | @responses.activate |
@@ -235,6 +282,21 @@ def test_create_contact_field_should_return_created_contact_field( |
235 | 282 | conftest.NOT_FOUND_RESPONSE, |
236 | 283 | conftest.NOT_FOUND_ERROR_MESSAGE, |
237 | 284 | ), |
| 285 | + ( |
| 286 | + conftest.RATE_LIMIT_ERROR_STATUS_CODE, |
| 287 | + conftest.RATE_LIMIT_ERROR_RESPONSE, |
| 288 | + conftest.RATE_LIMIT_ERROR_MESSAGE, |
| 289 | + ), |
| 290 | + ( |
| 291 | + conftest.INTERNAL_SERVER_ERROR_STATUS_CODE, |
| 292 | + conftest.INTERNAL_SERVER_ERROR_RESPONSE, |
| 293 | + conftest.INTERNAL_SERVER_ERROR_MESSAGE, |
| 294 | + ), |
| 295 | + ( |
| 296 | + conftest.VALIDATION_ERRORS_STATUS_CODE, |
| 297 | + VALIDATION_ERRORS_RESPONSE, |
| 298 | + VALIDATION_ERRORS_MESSAGE, |
| 299 | + ), |
238 | 300 | ], |
239 | 301 | ) |
240 | 302 | @responses.activate |
@@ -301,6 +363,39 @@ def test_update_contact_field_should_return_updated_contact_field( |
301 | 363 | conftest.NOT_FOUND_RESPONSE, |
302 | 364 | conftest.NOT_FOUND_ERROR_MESSAGE, |
303 | 365 | ), |
| 366 | + ( |
| 367 | + conftest.RATE_LIMIT_ERROR_STATUS_CODE, |
| 368 | + conftest.RATE_LIMIT_ERROR_RESPONSE, |
| 369 | + conftest.RATE_LIMIT_ERROR_MESSAGE, |
| 370 | + ), |
| 371 | + ( |
| 372 | + conftest.INTERNAL_SERVER_ERROR_STATUS_CODE, |
| 373 | + conftest.INTERNAL_SERVER_ERROR_RESPONSE, |
| 374 | + conftest.INTERNAL_SERVER_ERROR_MESSAGE, |
| 375 | + ), |
| 376 | + ( |
| 377 | + conftest.VALIDATION_ERRORS_STATUS_CODE, |
| 378 | + { |
| 379 | + "errors": { |
| 380 | + "usage": [ |
| 381 | + ( |
| 382 | + "This field is used in the steps of automation(s): " |
| 383 | + "%{automation names}." |
| 384 | + ), |
| 385 | + ( |
| 386 | + "This field is used in the conditions of segment(s): " |
| 387 | + "{segment names}." |
| 388 | + ), |
| 389 | + ] |
| 390 | + } |
| 391 | + }, |
| 392 | + ( |
| 393 | + "usage: This field is used in the steps of automation(s): " |
| 394 | + "%{automation names}.; " |
| 395 | + "usage: This field is used in the conditions of segment(s): " |
| 396 | + "{segment names}." |
| 397 | + ), |
| 398 | + ), |
304 | 399 | ], |
305 | 400 | ) |
306 | 401 | @responses.activate |
|
0 commit comments