Skip to content

Instantly share code, notes, and snippets.

@laser
Last active December 11, 2015 00:59
Show Gist options
  • Save laser/4520708 to your computer and use it in GitHub Desktop.
Save laser/4520708 to your computer and use it in GitHub Desktop.
def assertUserValidationException(fx):
def decorator(fx):
try:
fx()
except barrister.RpcException as e:
assert e.code == 1002
else:
assert False, "Should have thrown an RpcException with status code 1002"
return decorator
def assertIllegalOperationException(fx):
def decorator(fx):
try:
fx()
except barrister.RpcException as e:
assert e.code == 1004
else:
assert False, "Should have thrown an RpcException with status code 1004"
return decorator
@assertIllegalOperationException
def testOperation(self):
service.call_something()
@assertUserValidationException
def testInput(self):
service.call_something_else()
# i would rather...
@assertRpcException(1004)
def testOperation(self):
service.call_something()
@assertRpcException(1002)
def testInput(self):
service.call_something_else()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment