Skip to content

Commit 0f2df83

Browse files
committed
add import xlsx test
1 parent 7f0261f commit 0f2df83

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/api/test_import_xlsx.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from anyio import Path
2+
3+
import pytest
4+
from fastapi import status
5+
from httpx import AsyncClient
6+
7+
# Integration tests
8+
pytestmark = pytest.mark.anyio
9+
10+
11+
async def test_import_animals(client: AsyncClient):
12+
# Arrange
13+
expected_status = status.HTTP_201_CREATED
14+
headers = {"Content-type": "multipart/form-data; boundary={}"}
15+
16+
path = Path("tests/api/nonsense.xlsx")
17+
18+
_bytes = await path.read_bytes()
19+
20+
response = await client.post(
21+
"/nonsense/import",
22+
files={"xlsx": ("nonsense.xlsx", _bytes)},
23+
headers=headers,
24+
)
25+
26+
assert response.status_code == expected_status
27+
assert response.json() == {'filename': 'nonsense.xlsx', 'nonsense_records': 10}

0 commit comments

Comments
 (0)