Remediate the 2026-09-03 feature-test findings

This commit is contained in:
2026-09-03 17:14:53 -04:00
parent ddf41c3e65
commit ff9ae693a6
112 changed files with 5182 additions and 857 deletions

View File

@@ -118,3 +118,60 @@ def test_a_row_that_names_a_vendor_is_not_matched_by_its_text(db, fleet):
printer = Printer(vendorid=brother.vendorid, modelnumberid=None)
printer.vendor = brother
assert _printer_driver(printer, _universal()) is None
# --- the two fields the converger actually needs -----------------------------
#
# drivername is the exact string the INF declares, and it is what
# Add-PrinterDriver matches on - `name` is ours to choose and means nothing to
# Windows. vendorid attaches a universal driver (HP UPD, Xerox GPD) to a whole
# make. Neither was read from the request body, so both came back null on a
# 201, and there was no interface that could set them: the shipped converger
# had nothing to match and installed nothing, and driver-name drift could never
# be detected because the expected value was never stored.
def test_a_driver_keeps_the_inf_name_and_vendor_it_was_given(client, db,
auth_headers):
from plugins.printers.models import PrinterDriver
created = client.post('/api/printers/drivers', headers=auth_headers, json={
'name': 'HP universal',
'location': r'\\server\share\hpupd',
'drivername': 'HP Universal Printing PCL 6',
'vendorid': 1,
})
assert created.status_code == 201, created.get_json()
body = created.get_json()['data']
assert body['drivername'] == 'HP Universal Printing PCL 6'
assert body['vendorid'] == 1
stored = db.session.get(PrinterDriver, body['driverid'])
assert stored.drivername == 'HP Universal Printing PCL 6'
assert stored.vendorid == 1
def test_the_inf_name_and_vendor_can_be_changed_afterwards(client, db,
auth_headers):
created = client.post('/api/printers/drivers', headers=auth_headers, json={
'name': 'Xerox universal', 'location': r'\\server\share\xerox'})
driverid = created.get_json()['data']['driverid']
assert created.get_json()['data']['drivername'] is None
updated = client.put('/api/printers/drivers/%d' % driverid,
headers=auth_headers,
json={'drivername': 'Xerox Global Print Driver PCL6',
'vendorid': 2})
assert updated.status_code == 200, updated.get_json()
assert updated.get_json()['data']['drivername'] == \
'Xerox Global Print Driver PCL6'
assert updated.get_json()['data']['vendorid'] == 2
def test_a_blank_inf_name_clears_it_rather_than_storing_whitespace(
client, db, auth_headers):
"""An empty box means "not known", which the converger reads as "cannot
install this". A whitespace string would look set and match nothing."""
created = client.post('/api/printers/drivers', headers=auth_headers, json={
'name': 'Blank test', 'location': r'\\server\share\blank',
'drivername': ' '})
assert created.get_json()['data']['drivername'] is None