forked from tokiwi/preview-service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_app.py
31 lines (21 loc) · 825 Bytes
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import io
from starlette.testclient import TestClient
from app import app
def test_health_endpoint_succeeds():
client = TestClient(app)
response = client.get("/")
assert response.status_code == 200
def test_preview_endpoint_succeeds():
client = TestClient(app)
file = io.StringIO("plain text file data")
response = client.post("/preview/100x100", files={"file": file})
assert response.status_code == 200
def test_preview_endpoint_fails_on_empty_file():
client = TestClient(app)
response = client.post("/preview/100x100")
assert response.status_code == 400
def test_preview_endpoint_fails_on_undetected_mimetype():
client = TestClient(app)
file = io.BytesIO()
response = client.post("/preview/100x100", files={"file": file})
assert response.status_code == 500