12
12
from zope.component import getUtility
14
14
from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller
15
from canonical.testing.layers import DatabaseFunctionalLayer
15
from canonical.testing.layers import (
16
DatabaseFunctionalLayer,
19
from lp.answers.errors import (
20
AddAnswerContactError,
22
InvalidQuestionStateError,
23
NotAnswerContactError,
25
NotQuestionOwnerError,
16
28
from lp.registry.interfaces.person import IPersonSet
17
29
from lp.testing import (
18
31
TestCaseWithFactory,
19
32
celebrity_logged_in,
38
from lp.testing.views import create_webservice_error_view
41
class ErrorsTestCase(TestCase):
42
"""Test answers errors are exported as HTTPErrors."""
44
layer = FunctionalLayer
46
def test_AddAnswerContactError(self):
47
error_view = create_webservice_error_view(AddAnswerContactError())
48
self.assertEqual(400, error_view.status)
50
def test_FAQTargetError(self):
51
error_view = create_webservice_error_view(FAQTargetError())
52
self.assertEqual(400, error_view.status)
54
def test_InvalidQuestionStateError(self):
55
error_view = create_webservice_error_view(InvalidQuestionStateError())
56
self.assertEqual(400, error_view.status)
58
def test_NotAnswerContactError(self):
59
error_view = create_webservice_error_view(NotAnswerContactError())
60
self.assertEqual(400, error_view.status)
62
def test_NotMessageOwnerError(self):
63
error_view = create_webservice_error_view(NotMessageOwnerError())
64
self.assertEqual(400, error_view.status)
66
def test_NotQuestionOwnerError(self):
67
error_view = create_webservice_error_view(NotQuestionOwnerError())
68
self.assertEqual(400, error_view.status)
70
def test_QuestionTargetError(self):
71
error_view = create_webservice_error_view(QuestionTargetError())
72
self.assertEqual(400, error_view.status)
27
75
class TestQuestionRepresentation(TestCaseWithFactory):