Let a printer driver carry the name Windows actually matches on
The driver form and the API both dropped `drivername` and `vendorid`. POST returned 201 with both null, PUT accepted them and stored nothing, and no screen offered either field - so there was no interface in the product that could set them. That is not a cosmetic gap. `drivername` is the exact string the INF declares, and Add-PrinterDriver matches on it; `name` is ours to choose and means nothing to Windows. With it null the shipped converger has nothing to match and installs nothing, and the drift check that compares an observed driver name against the expected one could never fire, because the expected value was never stored. `vendorid` is how a universal driver (HP UPD, Xerox GPD) attaches to a whole make instead of needing a near-duplicate row per model. Both are now read on create and update, and the driver form gained the two fields with hints saying what they are for - the INF name box says plainly that leaving it blank means the converger cannot install that driver. A whitespace value clears rather than stores: an empty box means "not known", and a blank string would look set and match nothing. Three tests. Verified by planting: drop the two fields from the create path again and the round-trip test fails. Scope: product
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user