Skip to content
Permalink
Browse files

Added more reserved words, added test cases and list of capabilities …

…for testing internal name function
  • Loading branch information
simoncadman committed Sep 14, 2013
1 parent d51b152 commit 165dfc1049dce861ec62e5fb6e6dc713685edadd
Showing with 1,173 additions and 9 deletions.
  1. +1 −1 backend.py
  2. +1 −1 deleteaccount.py
  3. +1 −1 dynamicppd.py
  4. +1 −1 listcloudprinters.py
  5. +9 −1 printer.py
  6. +1 −1 reportissues.py
  7. +1 −1 setupcloudprint.py
  8. +1 −1 submitjob.py
  9. +20 −0 test_printer.py
  10. +1,136 −0 testfiles/capabilitylist
  11. +1 −1 upgrade.py
@@ -20,7 +20,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print CUPS Backend Version " + CCPVersion
sys.exit(0)

@@ -20,7 +20,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)

@@ -19,7 +19,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Dynamic PPD Generator Version " + CCPVersion
sys.exit(0)

@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Printer Lister Version " + CCPVersion
sys.exit(0)

@@ -24,6 +24,14 @@ class Printer:
requestors = None
requestor = None
cachedPrinterDetails = {}
reservedCapabilityWords = [
'Duplex', 'Resolution', 'Attribute', 'Choice', 'ColorDevice', 'ColorModel', 'ColorProfile',
'Copyright', 'CustomMedia', 'Cutter', 'Darkness', 'DriverType', 'FileName', 'Filter',
'Filter', 'Finishing', 'Font', 'Group', 'HWMargins', 'InputSlot', 'Installable',
'LocAttribute', 'ManualCopies', 'Manufacturer', 'MaxSize', 'MediaSize', 'MediaType',
'MinSize', 'ModelName', 'ModelNumber', 'Option', 'PCFileName', 'SimpleColorProfile',
'Throughput', 'UIConstraints', 'VariablePaperSize', 'Version', 'Color'
]

def __init__( self, requestors ):
"""Create an instance of Printer, with authorised requestor
@@ -397,7 +405,7 @@ def submitJob(self, printerid, jobtype, jobfile, jobname, printername, options="
def getInternalName ( self, details, internalType, capabilityName = None, existingList = [] ) :
returnValue = None
fixedNameMap = {}
reservedWords = [ 'Duplex', 'Resolution' ]
reservedWords = self.reservedCapabilityWords

# use fixed options for options we recognise
if internalType == "option":
@@ -19,7 +19,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Issue Reporting Script Version " + CCPVersion
sys.exit(0)

@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Setup Script Version " + CCPVersion
sys.exit(0)

@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20130912"
CCPVersion = "20130914"
print "CUPS Cloud Print Submit Job Version " + CCPVersion
sys.exit(0)

@@ -90,6 +90,26 @@ def test_invalidRequest ( ) :
testMock = MockRequestor()
assert testMock.doRequest('thisrequestisinvalid') == None

def test_internalName():
global printerItem

internalCapabilityTests = []

# generate test cases for each reserved word
#for word in printerItem.reservedCapabilityWords:
# internalCapabilityTests.append( { 'name' : word } )

# load test file and try all those
for filelineno, line in enumerate(open('testfiles/capabilitylist')):
internalCapabilityTests.append( { 'name' : line.decode("utf-8") } )

for internalTest in internalCapabilityTests:
assert printerItem.getInternalName( internalTest, 'capability' ) not in printerItem.reservedCapabilityWords
assert ':' not in printerItem.getInternalName( internalTest, 'capability' )
assert ' ' not in printerItem.getInternalName( internalTest, 'capability' )
assert len(printerItem.getInternalName( internalTest, 'capability' )) <= 30
assert len(printerItem.getInternalName( internalTest, 'capability' )) >= 1

def test_printers():
global printerItem, requestors

0 comments on commit 165dfc1

Please sign in to comment.
You can’t perform that action at this time.