blueeye-3184
refactor: move safety-stock logic to Inventory Optimization module and add tests
bdf918d Download web-development/backend/tests/test_api_data_source.py from apple-retail-study/Apple-Retail-Sales-Strategy: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/apple-retail-study/Apple-Retail-Sales-Strategy/resolve/main/web-development/backend/tests/test_api_data_source.py
- Command line
-
hf download hf://spaces/apple-retail-study/Apple-Retail-Sales-Strategy/web-development/backend/tests/test_api_data_source.py
-
curl -L -o test_api_data_source.py https://huggingface.co/spaces/apple-retail-study/Apple-Retail-Sales-Strategy/resolve/main/web-development/backend/tests/test_api_data_source.py
1.53 kB
| """ | |
| 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 | |