mirror of
https://github.com/vee1e/bulk-questionnaire-upload.git
synced 2026-09-01 17:57:10 +00:00
feat: update file parsing to return the actual mForm format
- Modified the parse_file endpoint to return data in mForm comptaible format instead of the previous schema. - Updated the get_form_by_id endpoint to return forms in the new tempData.json format. - Enhanced XLSFormParser to support the conversion of database format to tempData.json format. - Adjusted tests to validate the new response structure for parsed forms.
This commit is contained in:
parent
00ded49a4c
commit
86a45d02da
4 changed files with 730 additions and 46 deletions
|
|
@ -69,9 +69,28 @@ async def test_parse_with_valid_excel_file(client: httpx.AsyncClient):
|
|||
# Should return parsed form data without saving to DB
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert 'title' in body
|
||||
assert 'groups' in body
|
||||
assert 'metadata' in body
|
||||
|
||||
# New tempData.json format is an array containing form definitions
|
||||
assert isinstance(body, list)
|
||||
assert len(body) > 0
|
||||
|
||||
form_definition = body[0]
|
||||
assert '_id' in form_definition
|
||||
assert 'formId' in form_definition
|
||||
assert 'version' in form_definition
|
||||
assert 'language' in form_definition
|
||||
assert 'question' in form_definition
|
||||
assert isinstance(form_definition['question'], list)
|
||||
assert 'language' in form_definition
|
||||
assert isinstance(form_definition['language'], list)
|
||||
|
||||
# Check language array structure
|
||||
if form_definition['language']:
|
||||
lang_config = form_definition['language'][0]
|
||||
assert 'lng' in lang_config
|
||||
assert 'title' in lang_config
|
||||
assert 'question' in lang_config
|
||||
assert isinstance(lang_config['question'], list)
|
||||
else:
|
||||
# Skip test if no test file available
|
||||
pytest.skip("Test Excel file not found")
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue