dashboarddefaults: pick a kiosk from a dropdown (auto-fill FQDN) + Location wording
Adds GET /api/computers/display-kiosks - the displays that reported in (Kiosk type), each with its derived FQDN (F<serial>.<domain>). The Dashboard Defaults form gets a kiosk dropdown that fills the FQDN so admins pick a display instead of typing an IP; IP stays an optional manual field. Table shows FQDN or IP. 'Business Unit' label -> 'Location' on this page + the settings nav.
This commit is contained in:
45
tests/test_core/test_display_kiosks.py
Normal file
45
tests/test_core/test_display_kiosks.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""The /computers/display-kiosks picker: reporting displays with a derived FQDN.
|
||||
|
||||
Feeds the Dashboard Defaults kiosk dropdown so an admin picks a display instead
|
||||
of typing an IP. The FQDN is F<serial>.<domain> (device naming), derived from the
|
||||
BIOS serial the collector already reports.
|
||||
"""
|
||||
import pytest
|
||||
|
||||
from shopdb.core.models import AssetType
|
||||
from plugins.computers.models import ComputerType
|
||||
|
||||
KEY = 'testcollectorkey'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def collector_key(app):
|
||||
old = app.config.get('COLLECTOR_API_KEY')
|
||||
app.config['COLLECTOR_API_KEY'] = KEY
|
||||
yield KEY
|
||||
app.config['COLLECTOR_API_KEY'] = old
|
||||
|
||||
|
||||
def test_display_kiosks_derives_fqdn(client, db, collector_key):
|
||||
db.session.add(AssetType(assettype='computer', pluginname='computers',
|
||||
tablename='computers'))
|
||||
db.session.add(ComputerType(computertype='Kiosk'))
|
||||
db.session.commit()
|
||||
|
||||
# a display reports in via the collector (pctype -> Kiosk type, with serial)
|
||||
resp = client.post('/api/collector/computers', json={
|
||||
'hostname': 'WJDISP01', 'serialnumber': 'ABC1234',
|
||||
'pctype': 'gea-shopfloor-display',
|
||||
}, headers={'X-API-Key': KEY})
|
||||
assert resp.status_code == 200, resp.data
|
||||
|
||||
rows = client.get('/api/computers/display-kiosks').get_json()['data']
|
||||
match = [k for k in rows if k['hostname'] == 'WJDISP01']
|
||||
assert match, rows
|
||||
assert match[0]['fqdn'] == 'fabc1234.device.geaerospace.net'
|
||||
assert match[0]['serialnumber'] == 'ABC1234'
|
||||
|
||||
|
||||
def test_display_kiosks_empty_when_no_kiosk_type(client, db):
|
||||
# No 'Kiosk' ComputerType -> empty list, not an error.
|
||||
assert client.get('/api/computers/display-kiosks').get_json()['data'] == []
|
||||
Reference in New Issue
Block a user