def test_standard_exc(self): handler = ExceptionHandler() exc = Exception('Error') try: raise exc except Exception: model = handler(sys.exc_info(), {'test': 'blah'}) assert model['code'] == 500
def test_call(self): handler = ExceptionHandler() exc = ApplicationError('Error') try: raise exc except ApplicationError: model = handler(sys.exc_info(), {'test': 'blah'}) assert model['debug'] assert model['type'] == 'watson.mvc.exceptions.ApplicationError' assert model['test'] == 'blah'
def test_raised_from_cause(self): handler = ExceptionHandler() exc = Exception('Error') try: try: raise exc except Exception as e: raise ApplicationError('Something', status_code=300) from e except ApplicationError: model = handler(sys.exc_info(), {'test': 'blah'}) assert model['code'] == 300
def test_create(self): handler = ExceptionHandler({'test': 'blah'}) assert handler.config['test'] == 'blah'