Skip to content

Commit 485ac01

Browse files
committed
style(institutions): apply ruff format to router and tests
Made-with: Cursor
1 parent 3d1c57e commit 485ac01

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/webapp/routers/institutions.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,9 @@ def _resolve_merged_school_type_triple_for_patch(
257257

258258
def _require_single_institution_row_by_uuid(sess: Session, inst_id: str) -> InstTable:
259259
"""Load exactly one InstTable row by UUID or raise HTTP 400."""
260-
query_result = (
261-
sess.execute(
262-
select(InstTable).where(InstTable.id == str_to_uuid(inst_id))
263-
).all()
264-
)
260+
query_result = sess.execute(
261+
select(InstTable).where(InstTable.id == str_to_uuid(inst_id))
262+
).all()
265263
if not query_result or len(query_result) != 1:
266264
raise HTTPException(
267265
status_code=status.HTTP_400_BAD_REQUEST,
@@ -300,9 +298,7 @@ def _apply_institution_schema_updates_from_patch(
300298
) -> None:
301299
if school_type_changed:
302300
extra_allowed = (
303-
update_data["allowed_schemas"]
304-
if "allowed_schemas" in update_data
305-
else None
301+
update_data["allowed_schemas"] if "allowed_schemas" in update_data else None
306302
)
307303
existing_inst.schemas = _build_requested_schemas(
308304
extra_allowed,
@@ -322,12 +318,8 @@ def _patch_indicates_more_than_one_school_type(
322318
) -> bool:
323319
"""True if merged IDs plus explicit is_edvise/is_legacy flags imply more than one school type."""
324320
pdp_set = bool(pdp_id)
325-
edvise_flag = (
326-
update_data["is_edvise"] if "is_edvise" in update_data else False
327-
)
328-
legacy_flag = (
329-
update_data["is_legacy"] if "is_legacy" in update_data else False
330-
)
321+
edvise_flag = update_data["is_edvise"] if "is_edvise" in update_data else False
322+
legacy_flag = update_data["is_legacy"] if "is_legacy" in update_data else False
331323
edvise_set = bool(edvise_id) or bool(edvise_flag)
332324
legacy_set = bool(legacy_id) or bool(legacy_flag)
333325
return (pdp_set + edvise_set + legacy_set) > 1
@@ -391,9 +383,7 @@ def _build_requested_schemas_for_create(
391383
legacy_id: Optional[str],
392384
) -> list:
393385
"""Build the requested_schemas list from req and school-type IDs (same rules as PATCH)."""
394-
return _build_requested_schemas(
395-
req.allowed_schemas, pdp_id, edvise_id, legacy_id
396-
)
386+
return _build_requested_schemas(req.allowed_schemas, pdp_id, edvise_id, legacy_id)
397387

398388

399389
def _validate_and_prepare_create_institution(
@@ -597,9 +587,7 @@ def update_inst(
597587
final_edvise_id,
598588
final_legacy_id,
599589
school_type_changed,
600-
) = _resolve_merged_school_type_triple_for_patch(
601-
existing_inst, update_data, sess
602-
)
590+
) = _resolve_merged_school_type_triple_for_patch(existing_inst, update_data, sess)
603591
_persist_institution_patch_row_fields(
604592
existing_inst,
605593
update_data,

src/webapp/routers/institutions_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ def test_create_inst_duplicate_name_state_ok_when_existing_row_is_valid(
406406
assert data["edvise_id"] is None
407407

408408

409-
def test_create_inst_rejects_is_pdp_without_pdp_id(datakinder_client: TestClient) -> None:
409+
def test_create_inst_rejects_is_pdp_without_pdp_id(
410+
datakinder_client: TestClient,
411+
) -> None:
410412
"""is_pdp alone does not set a school type; pdp_id is required for PDP (POST parity)."""
411413
os.environ["ENV"] = "DEV"
412414
response = datakinder_client.post(
@@ -875,7 +877,9 @@ def test_update_inst_mutual_exclusivity_error(datakinder_client: TestClient) ->
875877
assert "Please choose one schema type" in response.json()["detail"]
876878

877879

878-
def test_update_inst_clear_edvise_id_requires_other_type(datakinder_client: TestClient) -> None:
880+
def test_update_inst_clear_edvise_id_requires_other_type(
881+
datakinder_client: TestClient,
882+
) -> None:
879883
"""PATCH cannot leave zero school types; clearing edvise must set another type."""
880884
MOCK_STORAGE.create_bucket.return_value = None
881885
MOCK_STORAGE.create_folders.return_value = None

0 commit comments

Comments
 (0)