def test_decorator(self): func = common.dummy_func() wrapped = exceptions.exceptionHTTPencode(func) self.assertTrue(callable(wrapped))
def test_500(self): func = common.dummy_func(raises=Exception) wrapped = exceptions.exceptionHTTPencode(func) output = wrapped() self.assertEqual(output.status_code, 500)
def test_409(self): func = common.dummy_func(raises=exceptions.AlreadyExistsException) wrapped = exceptions.exceptionHTTPencode(func) output = wrapped() self.assertEqual(output.status_code, 409)
def test_429(self): func = common.dummy_func(raises=exceptions.RateLimitException) wrapped = exceptions.exceptionHTTPencode(func) output = wrapped() self.assertEqual(output.status_code, 429)
def test_401(self): func = common.dummy_func(raises=exceptions.UnauthorizedException) wrapped = exceptions.exceptionHTTPencode(func) output = wrapped() self.assertEqual(output.status_code, 401) self.assertIn('WWW-Authenticate', output.headers)
def test_403(self): func = common.dummy_func(raises=exceptions.ForbiddenException) wrapped = exceptions.exceptionHTTPencode(func) output = wrapped() self.assertEqual(output.status_code, 403)