Replace os.remove() in conftest autouse fixture with per-table DELETE to avoid Windows SQLite file-lock PermissionError being swallowed silently and leaking state across tests. Remove the inline DELETE workaround from test_profile_api.py that was coupling the test to internal DB knowledge. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
|
|
def test_profile_update_accepts_new_fields():
|
|
from app.main import app
|
|
body = {
|
|
"name": "테스트",
|
|
"preferred_districts": {
|
|
"S": ["강남구", "서초구"],
|
|
"A": ["송파구"],
|
|
"B": [],
|
|
"C": [],
|
|
"D": [],
|
|
},
|
|
"min_match_score": 75,
|
|
"notify_enabled": True,
|
|
}
|
|
with TestClient(app) as client:
|
|
resp = client.put("/api/realestate/profile", json=body)
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["preferred_districts"]["S"] == ["강남구", "서초구"]
|
|
assert data["min_match_score"] == 75
|
|
assert data["notify_enabled"] is True
|
|
|
|
|
|
def test_profile_get_returns_defaults_for_new_fields():
|
|
from app.main import app
|
|
from app.db import upsert_profile
|
|
upsert_profile({"name": "기본"})
|
|
|
|
with TestClient(app) as client:
|
|
resp = client.get("/api/realestate/profile")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert data["preferred_districts"] == {}
|
|
assert data["min_match_score"] == 70
|
|
assert data["notify_enabled"] is True
|