mirror of
https://github.com/steelcityamir/safe-content-ai.git
synced 2024-09-11 18:37:31 +03:00
Update test_main.py
This commit is contained in:
parent
7c27abe4bc
commit
a1424abc2c
13
test_main.py
13
test_main.py
@ -1,16 +1,19 @@
|
||||
"""API Tests"""
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
file_name = "sunflower.jpg"
|
||||
FILE_NAME = "sunflower.jpg"
|
||||
|
||||
def test_read_main():
|
||||
response = client.post("/api/v1/detect", files={"file": (file_name, open(file_name, "rb"), "image/jpeg")})
|
||||
"""Tests that POST /api/v1/detect returns 200 OK with valid request body"""
|
||||
response = client.post("/api/v1/detect", files={"file": (FILE_NAME, open(FILE_NAME, "rb"), "image/jpeg")})
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"file_name": file_name, "is_nsfw": False, "confidence_percentage": 100.0}
|
||||
assert response.json() == {"file_name": FILE_NAME, "is_nsfw": False, "confidence_percentage": 100.0}
|
||||
|
||||
def test_invalid_input():
|
||||
"""Tests that POST /api/v1/detect returns 422 with empty request body"""
|
||||
response = client.post("/api/v1/detect", files={})
|
||||
assert response.status_code == 422
|
||||
|
||||
assert response.status_code == 422
|
||||
|
Loading…
Reference in New Issue
Block a user