|
7 | 7 | from requests_toolbelt.multipart.encoder import MultipartEncoder |
8 | 8 |
|
9 | 9 | from test.fixtures import API_VERSION, TEST_FILE_DIR, DICTIONARIES, FROZEN_TIME, ZIP_FILES_VALIDATE |
10 | | -from test.fixtures_json import JSON_RESPONSES, GEOJSON_RESPONSES |
| 10 | +from test.fixtures_json import JSON_RESPONSES, GEOJSON_RESPONSES, UNKNOWN_RULES_RESPONSE |
11 | 11 | from test.fixtures_plain_text import PLAIN_TEXT_RESPONSES |
12 | 12 |
|
13 | 13 |
|
@@ -424,3 +424,27 @@ async def test_validate_ags_and_zip(async_client, filename, zipped_files): |
424 | 424 | assert body['self'] is not None |
425 | 425 | assert len(body['data']) == len(expected_files) |
426 | 426 | assert {d['filename'] for d in body['data']} == expected_files |
| 427 | + |
| 428 | + |
| 429 | +@pytest.mark.asyncio |
| 430 | +async def test_validate_unknown_rules_json(async_client): |
| 431 | + # Arrange |
| 432 | + filename = TEST_FILE_DIR / 'example_ags.ags' |
| 433 | + file = ('files', (filename.name, open(filename, 'rb'), 'text/plain')) |
| 434 | + fields = [file] |
| 435 | + fields.append(('checkers', 'ags')) |
| 436 | + fields.append(('checkers', 'unknown')) |
| 437 | + fields.append(('fmt', 'json')) |
| 438 | + mp_encoder = MultipartEncoder(fields=fields) |
| 439 | + |
| 440 | + # Act |
| 441 | + async with async_client as ac: |
| 442 | + response = await ac.post( |
| 443 | + f'{API_VERSION}/validate/', |
| 444 | + headers={'Content-Type': mp_encoder.content_type}, |
| 445 | + data=mp_encoder.to_string()) |
| 446 | + |
| 447 | + # Assert |
| 448 | + assert response.status_code == 422 |
| 449 | + body = response.json() |
| 450 | + assert body == UNKNOWN_RULES_RESPONSE |
0 commit comments