Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Excluded untestable parts of client auth, test for print failure
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncadman committed Dec 30, 2012
1 parent 7d696cf commit 9857922
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 5 additions & 5 deletions oauth2client/client.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
from anyjson import simplejson from anyjson import simplejson


HAS_OPENSSL = False HAS_OPENSSL = False
try: try: # pragma: no cover
from oauth2client.crypt import Signer from oauth2client.crypt import Signer
from oauth2client.crypt import make_signed_jwt from oauth2client.crypt import make_signed_jwt
from oauth2client.crypt import verify_signed_jwt_with_certs from oauth2client.crypt import verify_signed_jwt_with_certs
HAS_OPENSSL = True HAS_OPENSSL = True
except ImportError: except ImportError: # pragma: no cover
pass pass


try: try: # pragma: no cover
from urlparse import parse_qsl from urlparse import parse_qsl
except ImportError: except ImportError: # pragma: no cover
from cgi import parse_qsl from cgi import parse_qsl


logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -88,7 +88,7 @@ class VerifyJwtTokenError(Error):
pass pass




def _abstract(): def _abstract(): # pragma: no cover
raise NotImplementedError('You need to override this function') raise NotImplementedError('You need to override this function')




Expand Down
2 changes: 1 addition & 1 deletion printer.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -347,6 +347,6 @@ def submitJob(self, printerid, jobtype, jobfile, jobname, printername ):
print('ERROR: Print job %s failed with %s', jobtype, responseobj['message']) print('ERROR: Print job %s failed with %s', jobtype, responseobj['message'])
return False return False


except Exception, error_msg: except Exception, error_msg: # pragma: no cover
print('ERROR: Print job %s failed with %s', jobtype, error_msg) print('ERROR: Print job %s failed with %s', jobtype, error_msg)
return False return False
8 changes: 7 additions & 1 deletion test_printer.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def mockSearch ( self, path, headers, data , boundary ) :
return json.dumps( result ) return json.dumps( result )


def mockSubmit ( self, path, headers, data , boundary ) : 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 ) return json.dumps( result )


def mockPrinter ( self, path, headers, data , boundary ) : def mockPrinter ( self, path, headers, data , boundary ) :
Expand Down Expand Up @@ -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.ps', 'Test Page', testprintername ) == False
assert printerItem.submitJob(printerId, 'ps', 'testfiles/Test Page Doesnt Exist.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 # delete test printer
connection.deletePrinter( testprintername ) connection.deletePrinter( testprintername )

0 comments on commit 9857922

Please sign in to comment.