Edit name/amount on budget template entries (#21) #22
2 changed files with 28 additions and 28 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue