/usr/share/pyshared/txaws/server/tests/test_exception.py is in python-txaws 0.2.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # -*- coding: utf-8 -*-
from unittest import TestCase
from txaws.server.exception import APIError
class APIErrorTestCase(TestCase):
def test_with_no_parameters(self):
"""
The L{APIError} constructor must be passed either a code/message pair
or a full response payload.
"""
self.assertRaises(RuntimeError, APIError, 400)
def test_with_response_and_code(self):
"""
If the L{APIError} constructor is passed a full response payload, it
can't be passed an error code.
"""
self.assertRaises(RuntimeError, APIError, 400, code="FooBar",
response="foo bar")
def test_with_response_and_message(self):
"""
If the L{APIError} constructor is passed a full response payload, it
can't be passed an error code.
"""
self.assertRaises(RuntimeError, APIError, 400, message="Foo Bar",
response="foo bar")
def test_with_code_and_no_message(self):
"""
If the L{APIError} constructor is passed an error code, it must be
passed an error message as well.
"""
self.assertRaises(RuntimeError, APIError, 400, code="FooBar")
def test_with_message_and_no_code(self):
"""
If the L{APIError} constructor is passed an error message, it must be
passed an error code as well.
"""
self.assertRaises(RuntimeError, APIError, 400, message="Foo Bar")
def test_with_string_status(self):
"""
The L{APIError} constructor can be passed a C{str} as status code, and
it will be converted to C{intp}.
"""
error = APIError("200", response="noes")
self.assertEqual(200, error.status)
def test_with_unicode_message(self):
"""
L{APIError} will convert message to plain ASCII if converted to string.
"""
error = APIError(400, code="APIError", message=u"cittá")
self.assertEqual(u"cittá", error.message)
self.assertEqual("citt?", str(error))
|