From 1c525f0202caf6c8b2e7df958cd6b12a48865bc2 Mon Sep 17 00:00:00 2001 From: archeious Date: Fri, 17 Apr 2026 19:11:01 -0600 Subject: [PATCH] refactor: remove POST /entries/{id}/notes, superseded by save route (#21) --- src/quartermaster/routes.py | 13 ----------- tests/test_notes.py | 43 ++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/quartermaster/routes.py b/src/quartermaster/routes.py index 6043e9e..c7c91a7 100644 --- a/src/quartermaster/routes.py +++ b/src/quartermaster/routes.py @@ -199,19 +199,6 @@ def get_section( return _render_section(request, db, section) -@router.post("/entries/{entry_id}/notes", response_class=HTMLResponse) -def update_entry_notes( - entry_id: int, - request: Request, - notes: str | None = Form(None), - db: Session = Depends(get_session), -) -> HTMLResponse: - updated = service.set_entry_notes(db, entry_id, notes) - if updated is None: - raise HTTPException(status_code=404, detail="entry not found") - return _render_section(request, db, updated.section) - - @router.post("/debt-target", response_class=HTMLResponse) def update_debt_target( request: Request, diff --git a/tests/test_notes.py b/tests/test_notes.py index 542492f..72731f4 100644 --- a/tests/test_notes.py +++ b/tests/test_notes.py @@ -91,26 +91,39 @@ def test_create_entry_route_accepts_notes(client): assert "3 mo cushion" in response.text -def test_update_entry_notes_route(client): +def test_update_entry_notes_via_save_route(client): + client.post( + "/sections/food/entries", + data={"name": "Groceries", "amount": "400.00"}, + ) + response = client.post( + "/entries/1", + data={"name": "Groceries", "amount": "400.00", "notes": "weekly"}, + ) + assert response.status_code == 200 + assert "weekly" in response.text + + +def test_update_entry_notes_empty_clears_via_save_route(client): + client.post( + "/sections/food/entries", + data={"name": "Groceries", "amount": "400.00", "notes": "weekly"}, + ) + response = client.post( + "/entries/1", + data={"name": "Groceries", "amount": "400.00", "notes": ""}, + ) + assert response.status_code == 200 + assert "note-badge" not in response.text + + +def test_old_entry_notes_route_is_removed(client): client.post( "/sections/food/entries", data={"name": "Groceries", "amount": "400.00"}, ) response = client.post("/entries/1/notes", data={"notes": "weekly"}) - assert response.status_code == 200 - assert "weekly" in response.text - - -def test_update_entry_notes_empty_clears(client): - client.post( - "/sections/food/entries", - data={"name": "Groceries", "amount": "400.00", "notes": "weekly"}, - ) - response = client.post("/entries/1/notes", data={"notes": ""}) - assert response.status_code == 200 - # the input's value="" still renders but the placeholder kicks in; - # specifically, no literal "weekly" anymore - assert "value=\"weekly\"" not in response.text + assert response.status_code == 404 def test_create_month_entry_route_accepts_notes(client):