File size: 1,534 Bytes
bdf918d | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """
GET /api/data-source ์๊ฒฉ ํ
์คํธ.
- ์๋ต ์คํค๋งยทํ์
ยทํ์ฉ ๊ฐ ๊ฒ์ฆ.
"""
import pytest
from fastapi.testclient import TestClient
def test_data_source_returns_200(client: TestClient) -> None:
r = client.get("/api/data-source")
assert r.status_code == 200
assert "application/json" in (r.headers.get("content-type") or "")
def test_data_source_is_dict(client: TestClient) -> None:
r = client.get("/api/data-source")
data = r.json()
assert isinstance(data, dict)
def test_data_source_has_required_keys(client: TestClient) -> None:
r = client.get("/api/data-source")
data = r.json()
assert "loader" in data
assert "quantity_unit" in data or "data_dir" in data or "source" in data
def test_data_source_loader_type(client: TestClient) -> None:
r = client.get("/api/data-source")
data = r.json()
loader = data.get("loader")
assert loader is None or isinstance(loader, str)
if isinstance(loader, str):
assert loader in ("model_server", "builtin", "sql", "csv", "none") or len(loader) >= 0
def test_data_source_source_type(client: TestClient) -> None:
r = client.get("/api/data-source")
data = r.json()
src = data.get("source")
if src is not None:
assert isinstance(src, str)
def test_data_source_sql_file_count_type(client: TestClient) -> None:
r = client.get("/api/data-source")
data = r.json()
n = data.get("sql_file_count")
if n is not None:
assert isinstance(n, int)
assert n >= 0
|