Last active
December 11, 2015 00:59
-
-
Save laser/4520708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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