test the assets route with an existing file
(test_client)
| 45 | |
| 46 | @pytest.mark.asyncio |
| 47 | async def test_assets(test_client): |
| 48 | """test the assets route with an existing file""" |
| 49 | assets_dir_path = "src/backend/static/assets" |
| 50 | assets_file_path = os.listdir(assets_dir_path)[0] |
| 51 | |
| 52 | with open(os.path.join(assets_dir_path, assets_file_path), "rb") as f: |
| 53 | assets_file = f.read() |
| 54 | |
| 55 | response = test_client.get(f"/assets/{assets_file_path}") |
| 56 | |
| 57 | assert response.status_code == 200 |
| 58 | assert response.headers["Content-Length"] == str(len(assets_file)) |
| 59 | assert assets_file == response.content |
nothing calls this directly
no outgoing calls
no test coverage detected