Per-type board rows with shared categories, a network device IP field, and two dark-mode dialogs

This commit is contained in:
2026-08-07 10:43:32 -04:00
parent bcf7a009f8
commit 7c5b1bc74e
12 changed files with 1154 additions and 829 deletions

View File

@@ -57,6 +57,39 @@ def test_update_network_device_ipaddress_upserts(client, db, auth_headers, netwo
assert len(comms) == 1 and comms[0].ipaddress == '10.0.0.9'
def test_clearing_the_ip_takes_it_back_out(client, db, auth_headers, network_setup):
"""Blanking the form field must clear the stored IP.
The upsert helper returned early on a blank value, so an address could be
typed and never removed - invisible until the form grew an IP field.
"""
from shopdb.core.models import Communication
created = client.post('/api/network', json={
'assetnumber': 'SW-09', 'name': 'Switch', 'ipaddress': '10.0.0.5',
}, headers=auth_headers).get_json()['data']
devid = created['networkdevice']['networkdeviceid']
cleared = client.put(f'/api/network/{devid}', json={'ipaddress': ''},
headers=auth_headers)
assert cleared.status_code == 200, cleared.get_json()
assert not cleared.get_json()['data']['ipaddress']
comms = Communication.query.filter_by(assetid=created['assetid']).all()
assert len(comms) == 1 and comms[0].ipaddress is None
def test_omitting_ipaddress_leaves_it_alone(client, db, auth_headers, network_setup):
"""A PUT that never mentions the field must not wipe the stored IP."""
created = client.post('/api/network', json={
'assetnumber': 'SW-10', 'name': 'Switch', 'ipaddress': '10.0.0.7',
}, headers=auth_headers).get_json()['data']
devid = created['networkdevice']['networkdeviceid']
updated = client.put(f'/api/network/{devid}', json={'hostname': 'sw-10'},
headers=auth_headers)
assert updated.get_json()['data']['ipaddress'] == '10.0.0.7'
def test_seed_reference_data_creates_ip_commtype(app, db):
"""The reference-data seed now creates the IP communication type the asset
import depends on."""