Skip to content

Commit bf57208

Browse files
authored
Merge pull request #187 from BritishGeologicalSurvey/test-for-incorrect-rules-string
Test for an unkown rules string
2 parents 074d758 + 7d5863f commit bf57208

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

test/fixtures_json.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,3 +1622,15 @@
16221622
'geojson_error': None
16231623
},
16241624
]
1625+
1626+
UNKNOWN_RULES_RESPONSE = {
1627+
'detail': [
1628+
{
1629+
'ctx': {'expected': "'ags' or 'bgs'"},
1630+
'input': 'unknown',
1631+
'loc': ['body', 'checkers', 1],
1632+
'msg': "Input should be 'ags' or 'bgs'",
1633+
'type': 'enum'
1634+
}
1635+
]
1636+
}

test/integration/test_validate.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from requests_toolbelt.multipart.encoder import MultipartEncoder
88

99
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
1111
from test.fixtures_plain_text import PLAIN_TEXT_RESPONSES
1212

1313

@@ -424,3 +424,27 @@ async def test_validate_ags_and_zip(async_client, filename, zipped_files):
424424
assert body['self'] is not None
425425
assert len(body['data']) == len(expected_files)
426426
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

Comments
 (0)