Permalink
Browse files

Excluded untestable parts of client auth, test for print failure

  • Loading branch information...
1 parent 7d696cf commit 9857922acf8d6e0eea58d68d0b2356ca9bc80202 @simoncadman committed Dec 30, 2012
Showing with 13 additions and 7 deletions.
  1. +5 −5 oauth2client/client.py
  2. +1 −1 printer.py
  3. +7 −1 test_printer.py
View
@@ -34,17 +34,17 @@
from anyjson import simplejson
HAS_OPENSSL = False
-try:
+try: # pragma: no cover
from oauth2client.crypt import Signer
from oauth2client.crypt import make_signed_jwt
from oauth2client.crypt import verify_signed_jwt_with_certs
HAS_OPENSSL = True
-except ImportError:
+except ImportError: # pragma: no cover
pass
-try:
+try: # pragma: no cover
from urlparse import parse_qsl
-except ImportError:
+except ImportError: # pragma: no cover
from cgi import parse_qsl
logger = logging.getLogger(__name__)
@@ -88,7 +88,7 @@ class VerifyJwtTokenError(Error):
pass
-def _abstract():
+def _abstract(): # pragma: no cover
raise NotImplementedError('You need to override this function')
View
@@ -347,6 +347,6 @@ def submitJob(self, printerid, jobtype, jobfile, jobname, printername ):
print('ERROR: Print job %s failed with %s', jobtype, responseobj['message'])
return False
- except Exception, error_msg:
+ except Exception, error_msg: # pragma: no cover
print('ERROR: Print job %s failed with %s', jobtype, error_msg)
return False
View
@@ -44,7 +44,10 @@ def mockSearch ( self, path, headers, data , boundary ) :
return json.dumps( result )
def mockSubmit ( self, path, headers, data , boundary ) :
- result = { 'success' : True }
+ if 'FAIL PAGE' in data:
+ result = { 'success' : False }
+ else:
+ result = { 'success' : True }
return json.dumps( result )
def mockPrinter ( self, path, headers, data , boundary ) :
@@ -224,5 +227,8 @@ def test_printers():
assert printerItem.submitJob(printerId, 'ps', 'testfiles/Test Page.ps', 'Test Page', testprintername ) == False
assert printerItem.submitJob(printerId, 'ps', 'testfiles/Test Page Doesnt Exist.ps', 'Test Page', testprintername ) == False
+ # test failure of print job
+ assert printerItem.submitJob(printerId, 'pdf', 'testfiles/Test Page.pdf', 'FAIL PAGE', testprintername ) == False
+
# delete test printer
connection.deletePrinter( testprintername )

0 comments on commit 9857922

Please sign in to comment.