12
12
from itertools import count
14
14
from pytz import utc
15
from zope.component import getUtility
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,
24
from lp.testing import (
20
32
class BugActivityStub:
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)
178
190
self.assertEqual([comment1, comment2], grouped)
179
191
self.assertEqual([activity1, activity2], comment1.activity)
180
192
self.assertEqual([activity3], comment2.activity)
195
class TestBugCommentVisibility(
196
BrowserTestCase, TestMessageVisibilityMixin):
198
layer = DatabaseFunctionalLayer
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
209
def getView(self, context, user=None, no_login=False):
210
"""Required by the mixin."""
211
view = self.getViewBrowser(
212
context=context.default_bugtask,
218
class TestBugHideCommentControls(
219
BrowserTestCase, TestHideMessageControlMixin):
221
layer = DatabaseFunctionalLayer
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)
231
def getView(self, context, user=None, no_login=False):
232
"""Required by the mixin."""
233
view = self.getViewBrowser(
234
context=context.default_bugtask,