(tmpdir: Path, test_client_factory: TestClientFactory)
| 191 | |
| 192 | |
| 193 | def test_multipart_request_multiple_files(tmpdir: Path, test_client_factory: TestClientFactory) -> None: |
| 194 | path1 = os.path.join(tmpdir, "test1.txt") |
| 195 | with open(path1, "wb") as file: |
| 196 | file.write(b"<file1 content>") |
| 197 | |
| 198 | path2 = os.path.join(tmpdir, "test2.txt") |
| 199 | with open(path2, "wb") as file: |
| 200 | file.write(b"<file2 content>") |
| 201 | |
| 202 | client = test_client_factory(app) |
| 203 | with open(path1, "rb") as f1, open(path2, "rb") as f2: |
| 204 | response = client.post("/", files={"test1": f1, "test2": ("test2.txt", f2, "text/plain")}) |
| 205 | assert response.json() == { |
| 206 | "test1": { |
| 207 | "filename": "test1.txt", |
| 208 | "size": 15, |
| 209 | "content": "<file1 content>", |
| 210 | "content_type": "text/plain", |
| 211 | }, |
| 212 | "test2": { |
| 213 | "filename": "test2.txt", |
| 214 | "size": 15, |
| 215 | "content": "<file2 content>", |
| 216 | "content_type": "text/plain", |
| 217 | }, |
| 218 | } |
| 219 | |
| 220 | |
| 221 | def test_multipart_request_multiple_files_with_headers(tmpdir: Path, test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected