~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/browser/tests/test_bugcomment.py

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
from itertools import count
13
13
 
14
14
from pytz import utc
 
15
from zope.component import getUtility
15
16
 
 
17
from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
 
18
from canonical.testing.layers import DatabaseFunctionalLayer
16
19
from lp.bugs.browser.bugcomment import group_comments_with_activity
17
 
from lp.testing import TestCase
 
20
from lp.coop.answersbugs.visibility import (
 
21
    TestHideMessageControlMixin,
 
22
    TestMessageVisibilityMixin,
 
23
    )
 
24
from lp.testing import (
 
25
    BrowserTestCase,
 
26
    person_logged_in,
 
27
    celebrity_logged_in,
 
28
    TestCase,
 
29
    )
18
30
 
19
31
 
20
32
class BugActivityStub:
42
54
 
43
55
    def __repr__(self):
44
56
        return "BugCommentStub(%r, %d, %r)" % (
45
 
            self.datecreated.strftime('%Y-%m-%d--%H%M'), 
 
57
            self.datecreated.strftime('%Y-%m-%d--%H%M'),
46
58
            self.index, self.owner)
47
59
 
48
60
 
178
190
        self.assertEqual([comment1, comment2], grouped)
179
191
        self.assertEqual([activity1, activity2], comment1.activity)
180
192
        self.assertEqual([activity3], comment2.activity)
 
193
 
 
194
 
 
195
class TestBugCommentVisibility(
 
196
        BrowserTestCase, TestMessageVisibilityMixin):
 
197
 
 
198
    layer = DatabaseFunctionalLayer
 
199
 
 
200
    def makeHiddenMessage(self):
 
201
        """Required by the mixin."""
 
202
        with celebrity_logged_in('admin'):
 
203
            bug = self.factory.makeBug()
 
204
            comment = self.factory.makeBugComment(
 
205
                    bug=bug, body=self.comment_text)
 
206
            comment.visible = False
 
207
        return bug
 
208
 
 
209
    def getView(self, context, user=None, no_login=False):
 
210
        """Required by the mixin."""
 
211
        view = self.getViewBrowser(
 
212
            context=context.default_bugtask,
 
213
            user=user,
 
214
            no_login=no_login)
 
215
        return view
 
216
 
 
217
 
 
218
class TestBugHideCommentControls(
 
219
        BrowserTestCase, TestHideMessageControlMixin):
 
220
 
 
221
    layer = DatabaseFunctionalLayer
 
222
 
 
223
    def getContext(self):
 
224
        """Required by the mixin."""
 
225
        administrator = getUtility(ILaunchpadCelebrities).admin.teamowner
 
226
        bug = self.factory.makeBug()
 
227
        with person_logged_in(administrator):
 
228
            self.factory.makeBugComment(bug=bug)
 
229
        return bug
 
230
 
 
231
    def getView(self, context, user=None, no_login=False):
 
232
        """Required by the mixin."""
 
233
        view = self.getViewBrowser(
 
234
            context=context.default_bugtask,
 
235
            user=user,
 
236
            no_login=no_login)
 
237
        return view