~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/tests/test_question_webservice.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-23 16:26:26 UTC
  • mfrom: (13099.1.14 answers-api-4)
  • Revision ID: launchpad@pqm.canonical.com-20110523162626-m06mv9uf94d7prkm
[r=henninge][bug=786297] Consolidate and export question errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
from zope.component import getUtility
13
13
 
14
14
from canonical.launchpad.testing.pages import LaunchpadWebServiceCaller
15
 
from canonical.testing.layers import DatabaseFunctionalLayer
 
15
from canonical.testing.layers import (
 
16
    DatabaseFunctionalLayer,
 
17
    FunctionalLayer,
 
18
    )
 
19
from lp.answers.errors import (
 
20
    AddAnswerContactError,
 
21
    FAQTargetError,
 
22
    InvalidQuestionStateError,
 
23
    NotAnswerContactError,
 
24
    NotMessageOwnerError,
 
25
    NotQuestionOwnerError,
 
26
    QuestionTargetError,
 
27
    )
16
28
from lp.registry.interfaces.person import IPersonSet
17
29
from lp.testing import (
 
30
    TestCase,
18
31
    TestCaseWithFactory,
19
32
    celebrity_logged_in,
20
33
    launchpadlib_for,
22
35
    person_logged_in,
23
36
    ws_object,
24
37
    )
 
38
from lp.testing.views import create_webservice_error_view
 
39
 
 
40
 
 
41
class ErrorsTestCase(TestCase):
 
42
    """Test answers errors are exported as HTTPErrors."""
 
43
 
 
44
    layer = FunctionalLayer
 
45
 
 
46
    def test_AddAnswerContactError(self):
 
47
        error_view = create_webservice_error_view(AddAnswerContactError())
 
48
        self.assertEqual(400, error_view.status)
 
49
 
 
50
    def test_FAQTargetError(self):
 
51
        error_view = create_webservice_error_view(FAQTargetError())
 
52
        self.assertEqual(400, error_view.status)
 
53
 
 
54
    def test_InvalidQuestionStateError(self):
 
55
        error_view = create_webservice_error_view(InvalidQuestionStateError())
 
56
        self.assertEqual(400, error_view.status)
 
57
 
 
58
    def test_NotAnswerContactError(self):
 
59
        error_view = create_webservice_error_view(NotAnswerContactError())
 
60
        self.assertEqual(400, error_view.status)
 
61
 
 
62
    def test_NotMessageOwnerError(self):
 
63
        error_view = create_webservice_error_view(NotMessageOwnerError())
 
64
        self.assertEqual(400, error_view.status)
 
65
 
 
66
    def test_NotQuestionOwnerError(self):
 
67
        error_view = create_webservice_error_view(NotQuestionOwnerError())
 
68
        self.assertEqual(400, error_view.status)
 
69
 
 
70
    def test_QuestionTargetError(self):
 
71
        error_view = create_webservice_error_view(QuestionTargetError())
 
72
        self.assertEqual(400, error_view.status)
25
73
 
26
74
 
27
75
class TestQuestionRepresentation(TestCaseWithFactory):