Add custom fields + warranty plugin, rework settings into two-pane shell
Feature work from the 2026-07 session: Settings IA - Replace the flat 27-card settings hub with a persistent two-pane shell (SettingsLayout.vue): grouped, searchable left rail + content pane. - Nest all settings/* routes under the shell via router post-processing; shared nav catalog in settingsNav.js. Group by asset class (PCs, Printers, Equipment, Network) so per-type settings stop scattering. Custom fields (core) - customfields + customfieldvalues tables (migration 7d14), CRUD API at /api/customfields, per-asset value get/save. - Settings management page + reusable CustomFieldsSection (detail) and CustomFieldsInputs (form) wired into all four asset types. Warranty (new plugin) - plugins/warranty: warranties + warrantyassets (migration 7d15), derived coverage status, provider abstraction (manual now; Dell/Lenovo/HP stubs). - API CRUD + per-asset panel + report buckets; WarrantyPanel on all four detail pages; Warranties management page; Warranty report + Reports card. - Seed warranty.* permissions. Printer drivers - printerdrivers table (migration 7d13) linked to printer models; drivers now surface on the matching printer's detail page. Other - PCDetail rebalanced (Network + Status + Warranty + custom fields on the right). - Rename PCs list "Features" column to "Remote Access"; fix badge hover underline. - Drop equipment islocationonly field. - Centralize asset-type label/route maps into utils/assetTypes.js. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
69
tests/test_plugins/test_pc_default_printer.py
Normal file
69
tests/test_plugins/test_pc_default_printer.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""Tests for the per-PC default-printer endpoint (/api/printers/pc-default).
|
||||
|
||||
Parity with classic apipcdefaultprinter.asp: the signed printer-installer EXE
|
||||
preselects a PC's default printer by machine (asset) number. The link is a
|
||||
`defaultprinter` asset relationship (PC asset -> printer asset).
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from shopdb.core.models import Asset, AssetType, AssetRelationship, RelationshipType
|
||||
from plugins.printers.models import Printer
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def scene(db):
|
||||
"""A PC asset, a printer asset, and the defaultprinter relationship type."""
|
||||
pc_type = AssetType(assettype='computer', pluginname='computers', tablename='computers')
|
||||
pr_type = AssetType(assettype='printer', pluginname='printers', tablename='printers')
|
||||
dp_type = RelationshipType(relationshiptype='defaultprinter', description='PC to default printer')
|
||||
db.session.add_all([pc_type, pr_type, dp_type])
|
||||
db.session.flush()
|
||||
|
||||
pc = Asset(assetnumber='3210', name='CSF04 PC', assettypeid=pc_type.assettypeid, isactive=True)
|
||||
pr_asset = Asset(assetnumber='PRN-01', name='Materials HP', assettypeid=pr_type.assettypeid, isactive=True)
|
||||
db.session.add_all([pc, pr_asset])
|
||||
db.session.flush()
|
||||
|
||||
printer = Printer(assetid=pr_asset.assetid, windowsname='HP-CSF04-Materials')
|
||||
db.session.add(printer)
|
||||
db.session.commit()
|
||||
|
||||
return {'pc': pc, 'printer_asset': pr_asset, 'printer': printer, 'dp_type': dp_type}
|
||||
|
||||
|
||||
def _link_default(db, pc, printer_asset, dp_type):
|
||||
db.session.add(AssetRelationship(
|
||||
sourceassetid=pc.assetid,
|
||||
targetassetid=printer_asset.assetid,
|
||||
relationshiptypeid=dp_type.relationshiptypeid,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def test_returns_default_printer_for_pc(client, db, scene):
|
||||
_link_default(db, scene['pc'], scene['printer_asset'], scene['dp_type'])
|
||||
|
||||
resp = client.get('/api/printers/pc-default?machine=3210')
|
||||
assert resp.status_code == 200
|
||||
data = resp.get_json()['data']
|
||||
assert data['printerid'] == scene['printer'].printerid
|
||||
assert data['windowsname'] == 'HP-CSF04-Materials'
|
||||
|
||||
|
||||
def test_pc_without_default_returns_empty(client, db, scene):
|
||||
resp = client.get('/api/printers/pc-default?machine=3210')
|
||||
assert resp.status_code == 200
|
||||
assert resp.get_json()['data'] == {}
|
||||
|
||||
|
||||
def test_unknown_machine_returns_empty(client, db, scene):
|
||||
resp = client.get('/api/printers/pc-default?machine=NOPE')
|
||||
assert resp.status_code == 200
|
||||
assert resp.get_json()['data'] == {}
|
||||
|
||||
|
||||
def test_missing_machine_param_returns_empty(client, db, scene):
|
||||
resp = client.get('/api/printers/pc-default')
|
||||
assert resp.status_code == 200
|
||||
assert resp.get_json()['data'] == {}
|
||||
Reference in New Issue
Block a user