Charge all batteries across sub-components from parent device

This commit is contained in:
2026-06-09 21:42:08 -05:00
parent 27ed4c9420
commit ab1340998e
3 changed files with 64 additions and 3 deletions
+29 -2
View File
@@ -1066,5 +1066,32 @@ def test_parent_battery_summary_flat(client):
# Both child names linked in the component column
assert b"Sensor A" in resp.data
assert b"Sensor B" in resp.data
# Only one "Installed Batteries" heading
assert resp.data.count(b"Installed Batteries") == 1
# Flat table heading appears once (not duplicated per sub-component)
assert resp.data.count(b"<h2>Installed Batteries</h2>") == 1
def test_device_charge_all_parent(client):
_setup_parent_with_two_children(client)
client.post("/battery/add", data={"brand": "Eneloop", "label": "E001", "size": "AA"})
client.post("/battery/add", data={"brand": "Eneloop", "label": "E002", "size": "AA"})
client.post("/device/2/install-one", data={"battery_id": "1"})
client.post("/device/3/install-one", data={"battery_id": "2"})
resp = client.post(
"/device/1/charge-all",
data={"charged_date": "2025-06-01", "increment_cycles": "1"},
follow_redirects=True,
)
assert resp.status_code == 200
assert b"Logged charge for 2 batteri" in resp.data
assert b"+cycles" in resp.data
def test_device_charge_all_parent_no_installed(client):
_setup_parent_with_two_children(client)
resp = client.post(
"/device/1/charge-all",
data={"charged_date": "2025-06-01"},
follow_redirects=True,
)
assert resp.status_code == 200
assert b"No installed batteries" in resp.data