Make device.battery_size NOT NULL in schema and tests
This commit is contained in:
@@ -159,7 +159,7 @@ def test_poll_updates_installed_batteries(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/1/assign", data={"device_id": "1"})
|
||||
# Set ha_entity_id on device
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev A", "battery_slots": "2", "ha_entity_id": "sensor.dev_a_battery"
|
||||
"name": "Dev A", "battery_slots": "2", "battery_size": "AA", "ha_entity_id": "sensor.dev_a_battery"
|
||||
})
|
||||
|
||||
from ha_client import HomeAssistantClient
|
||||
@@ -188,7 +188,7 @@ def test_poll_skips_uninstalled_batteries(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/add", data={"brand": "X", "count": "1"})
|
||||
# Set entity on device but do NOT install the battery
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev B", "battery_slots": "1", "ha_entity_id": "sensor.dev_b_battery"
|
||||
"name": "Dev B", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.dev_b_battery"
|
||||
})
|
||||
|
||||
from ha_client import HomeAssistantClient
|
||||
@@ -232,7 +232,7 @@ def test_poll_handles_api_error_gracefully(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/add", data={"brand": "X", "count": "1"})
|
||||
ha_client_f.post("/battery/1/assign", data={"device_id": "1"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev D", "battery_slots": "1", "ha_entity_id": "sensor.dev_d"
|
||||
"name": "Dev D", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.dev_d"
|
||||
})
|
||||
|
||||
from ha_client import HomeAssistantClient
|
||||
@@ -352,7 +352,7 @@ def test_device_detail_shows_ha_field(ha_client_f):
|
||||
def test_edit_device_ha_entity_id_saves(ha_client_f):
|
||||
ha_client_f.post("/device/add", data={"name": "Dev F", "battery_slots": "1", "battery_size": "AA"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev F", "battery_slots": "1", "ha_entity_id": "sensor.my_remote"
|
||||
"name": "Dev F", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.my_remote"
|
||||
})
|
||||
resp = ha_client_f.get("/device/1")
|
||||
assert b"sensor.my_remote" in resp.data
|
||||
@@ -361,11 +361,11 @@ def test_edit_device_ha_entity_id_saves(ha_client_f):
|
||||
def test_edit_device_ha_entity_id_clear(ha_client_f):
|
||||
ha_client_f.post("/device/add", data={"name": "Dev G", "battery_slots": "1", "battery_size": "AA"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev G", "battery_slots": "1", "ha_entity_id": "sensor.foo"
|
||||
"name": "Dev G", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.foo"
|
||||
})
|
||||
# Now clear it
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev G", "battery_slots": "1", "ha_entity_id": ""
|
||||
"name": "Dev G", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": ""
|
||||
})
|
||||
resp = ha_client_f.get("/device/1")
|
||||
assert b"sensor.foo" not in resp.data
|
||||
@@ -419,7 +419,7 @@ def test_poll_skips_update_when_percentage_unchanged(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/add", data={"brand": "X", "count": "1"})
|
||||
ha_client_f.post("/battery/1/assign", data={"device_id": "1"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev NoCh", "battery_slots": "1", "ha_entity_id": "sensor.noch"
|
||||
"name": "Dev NoCh", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.noch"
|
||||
})
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
@@ -450,7 +450,7 @@ def test_poll_creates_pct_log_on_change(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/add", data={"brand": "X", "count": "1"})
|
||||
ha_client_f.post("/battery/1/assign", data={"device_id": "1"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev Chg", "battery_slots": "1", "ha_entity_id": "sensor.chg"
|
||||
"name": "Dev Chg", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.chg"
|
||||
})
|
||||
|
||||
from ha_client import HomeAssistantClient
|
||||
@@ -521,7 +521,7 @@ def test_device_detail_shows_live_pct(ha_app, ha_client_f):
|
||||
"""Opening a device page fetches live % from HA and displays it."""
|
||||
ha_client_f.post("/device/add", data={"name": "Dev Live", "battery_slots": "1", "battery_size": "AA"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev Live", "battery_slots": "1", "ha_entity_id": "sensor.live_test"
|
||||
"name": "Dev Live", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.live_test"
|
||||
})
|
||||
|
||||
mock_resp = MagicMock()
|
||||
@@ -541,7 +541,7 @@ def test_device_detail_updates_battery_on_load(ha_app, ha_client_f):
|
||||
ha_client_f.post("/battery/add", data={"brand": "X", "count": "1"})
|
||||
ha_client_f.post("/battery/1/assign", data={"device_id": "1"})
|
||||
ha_client_f.post("/device/1/edit", data={
|
||||
"name": "Dev Update", "battery_slots": "1", "ha_entity_id": "sensor.update_test"
|
||||
"name": "Dev Update", "battery_slots": "1", "battery_size": "AA", "ha_entity_id": "sensor.update_test"
|
||||
})
|
||||
|
||||
mock_resp = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user