The header's Selective flag read school_info.admissions_policy, which the detail endpoint never sent, so no school page could flag Selective while its search row did (staging E2E: The Grammar School at Leeds). The detail payload now carries it, and a contract test checks it carries every field the header's flags read. Sending it would have switched on two older copies of the tag logic #176 fixed in the rows. The Admissions section and the cut-off note both tested includes('selective'), so every non-selective secondary would have read "entry is by selective examination". The section also counted "None" as a faith: Burntwood reads "a faith-based admissions priority (None)" today. All of them now share isSelective() and hasReligiousCharacter(), which also treats "Not applicable" as no faith, as the place table already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
"""The school page's header flags (nextjs-app/lib/schoolFacts.ts) read seven
|
|
school_info fields, so the detail payload must carry every one.
|
|
|
|
It lacked admissions_policy, so no school page could flag Selective while its
|
|
search row did: Tiffin and The Grammar School at Leeds showed the tag in
|
|
search and nothing on their own pages.
|
|
"""
|
|
|
|
import numpy as np
|
|
import pandas as pd
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
# The fields schoolFlags() picks from School (FlagFields in lib/schoolFacts.ts).
|
|
FLAG_FIELDS = (
|
|
"type_group", "admissions_policy", "gender", "religious_denomination",
|
|
"nursery_provision", "has_sixth_form", "phase",
|
|
)
|
|
|
|
|
|
def _school_df() -> pd.DataFrame:
|
|
return pd.DataFrame([{
|
|
"urn": 136910, "school_name": "Tiffin School", "phase": "Secondary",
|
|
"school_type": "Academy converter", "admissions_policy": "Selective",
|
|
"gender": "Boys", "religious_denomination": "Christian",
|
|
"nursery_provision": "Not applicable", "has_sixth_form": True,
|
|
"age_range": "11-18", "local_authority": "Kingston upon Thames",
|
|
"address": "Queen Elizabeth Road, Kingston upon Thames, KT2 6RL",
|
|
"postcode": "KT2 6RL", "latitude": 51.41, "longitude": -0.30,
|
|
"year": 202425, "attainment_8_score": 75.0, "total_pupils": 200,
|
|
"gias_total_pupils": 1478, "ofsted_grade": np.nan,
|
|
}])
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(monkeypatch):
|
|
from backend import app as app_module
|
|
|
|
monkeypatch.setattr(app_module, "load_school_data", _school_df)
|
|
monkeypatch.setattr(app_module, "load_latest_school_data", _school_df)
|
|
monkeypatch.setattr(app_module, "get_supplementary_data", lambda db, urn: {})
|
|
monkeypatch.setattr(app_module, "_place_registry", None)
|
|
return TestClient(app_module.app, raise_server_exceptions=False)
|
|
|
|
|
|
def test_the_school_page_carries_every_field_its_flags_read(client):
|
|
resp = client.get("/api/schools/136910")
|
|
assert resp.status_code == 200, resp.text
|
|
info = resp.json()["school_info"]
|
|
assert [f for f in FLAG_FIELDS if f not in info] == []
|
|
|
|
|
|
def test_the_school_page_says_a_selective_school_is_selective(client):
|
|
info = client.get("/api/schools/136910").json()["school_info"]
|
|
assert info["admissions_policy"] == "Selective"
|