api/v1/schema n'est plus auth, schema renvoie table schema, adaptation des tests #78

This commit is contained in:
Colin Maudry
2026-06-16 17:03:14 +02:00
parent fede22f314
commit ffaf200c07
3 changed files with 16 additions and 19 deletions
+10 -11
View File
@@ -1,19 +1,18 @@
def test_schema_without_token_returns_401(api_client):
def test_schema_accessible_without_token(api_client):
client, _ = api_client
resp = client.get("/api/v1/schema")
assert resp.status_code == 401
assert resp.status_code == 200
def test_schema_returns_columns(api_client, valid_token_header):
def test_schema_returns_fields(api_client):
client, _ = api_client
resp = client.get("/api/v1/schema", headers=valid_token_header)
resp = client.get("/api/v1/schema")
assert resp.status_code == 200
data = resp.get_json()
assert "columns" in data
assert isinstance(data["columns"], list)
assert len(data["columns"]) > 0
first = data["columns"][0]
assert set(first.keys()) >= {"name", "type"}
# uid doit être présent dans le schéma DECP de test
names = [c["name"] for c in data["columns"]]
assert "fields" in data
assert isinstance(data["fields"], list)
assert len(data["fields"]) > 0
first = data["fields"][0]
assert set(first.keys()) >= {"name", "type", "title", "description"}
names = [f["name"] for f in data["fields"]]
assert "uid" in names
+3 -3
View File
@@ -29,7 +29,7 @@ def test_after_request_hook_increments_counter_async(api_client, valid_token_hea
# Faire une requête (qui doit déclencher l'incrément)
client.get("/api/v1/health") # pas authentifiée → ne compte pas
client.get("/api/v1/schema", headers=valid_token_header)
client.get("/api/v1/data", headers=valid_token_header) # /schema est public
tracking.flush(timeout=2.0)
@@ -49,7 +49,7 @@ def test_matomo_disabled_skips_call(monkeypatch, api_client, valid_token_header)
"_post_matomo",
lambda **kw: called.append(kw),
)
client.get("/api/v1/health")
client.get("/api/v1/data", headers=valid_token_header) # authentifiée → hook actif
tracking.flush(timeout=2.0)
assert called == []
@@ -69,7 +69,7 @@ def test_matomo_enabled_posts_event(monkeypatch, api_client, valid_token_header)
)
client, _ = api_client
client.get("/api/v1/schema", headers=valid_token_header)
client.get("/api/v1/data", headers=valid_token_header) # /schema est public
tracking.flush(timeout=2.0)
assert len(captured) == 1