Flask testing, post file and nested dictionaries Flask testing, post file and nested dictionaries flask flask

Flask testing, post file and nested dictionaries


I ran into a similar issue, and what ended up working for me was changing the data approach to exclude nested dicts. Taking your sample JSON, doing the following should allow it to clear the EnvironBuilder:

data_json = {    "attachments": [],    "Ids": [],    "globalServiceOptions": [json.dumps({  # Dump all nested JSON to a string representation            "globalServiceOptionId": {                "id": 2,                "agentServiceId": {                    "id": 2                },                "serviceOptionName": "Time",                "value": "T_last",                "required": false,                "defaultValue": "T_last",                "description": "UTC Timestamp",                "serviceOptionType": "TIME"            },            "name": "Time",            "value": null        })    ]}builder = EnvironBuilder(path='/' + endpoint,                             method='POST',                              data=data_json,                            content_type="application/json")

Taking the approach above still allowed the nested dict/JSON to be passed appropriately while clearing the werkzeug limitation.