I am trying to test fastapi router that get List of files. In html request using JS its working but I need to test it. I am using TestClient from fastapi, when I am trying so send list I get status code 422 so I go which documentry and try dict
but than I get list of only 1 file.
router
@router.post('/uploadone')
async def upload_file(response: Response,files:List = File(...)):
try:
properties = json.loads(files[len(files)-1])
check_file_type(files[:len(files)-1])
test
def test_uploadone(self):
with open('upload_data/system_test/properties.json', 'rb') as file1:
json_file = json.load(file1)
with open('upload_data/system_test/heatmap1.csv', 'rb') as file:
body = file.read()
response = self.client.post('/actions/uploadone',
files={'files':('design_matrix1.csv', body),'json':
('prop.json', json.dumps(json_file))})
self.assertTrue(response.status_code == 200)
thanks for helping