239
239
def test_getRecipientFilterData_empty(self):
240
240
# When there is empty input, there is empty output.
241
241
self.assertEqual(
242
BugNotificationSet().getRecipientFilterData({}, []),
242
BugNotificationSet().getRecipientFilterData(self.bug, {}, []),
244
244
self.assertEqual(
245
245
BugNotificationSet().getRecipientFilterData(
246
{}, [self.notification]),
246
self.bug, {}, [self.notification]),
249
249
def test_getRecipientFilterData_other_persons(self):
265
265
subscriber2: {'sources': sources2,
266
266
'filter descriptions': [u'Special Filter!']}},
267
267
BugNotificationSet().getRecipientFilterData(
268
{self.subscriber: sources, subscriber2: sources2},
268
self.bug, {self.subscriber: sources, subscriber2: sources2},
269
269
[self.notification, notification2]))
271
271
def test_getRecipientFilterData_match(self):
277
277
{self.subscriber: {'sources': sources,
278
278
'filter descriptions': ['Special Filter!']}},
279
279
BugNotificationSet().getRecipientFilterData(
280
{self.subscriber: sources}, [self.notification]))
280
self.bug, {self.subscriber: sources}, [self.notification]))
282
282
def test_getRecipientFilterData_multiple_notifications_match(self):
283
283
# When there are bug filters for the recipient for multiple
291
291
{self.subscriber: {'sources': sources,
292
292
'filter descriptions': ['Another Filter!', 'Special Filter!']}},
293
293
BugNotificationSet().getRecipientFilterData(
294
{self.subscriber: sources},
294
self.bug, {self.subscriber: sources},
295
295
[self.notification, self.notification2]))
297
297
def test_getRecipientFilterData_mute(self):
306
306
self.assertEqual(
308
308
BugNotificationSet().getRecipientFilterData(
309
{self.subscriber: sources}, [self.notification]))
309
self.bug, {self.subscriber: sources}, [self.notification]))
311
311
def test_getRecipientFilterData_mute_one_person_of_two(self):
312
312
self.includeFilterInNotification()
327
327
{subscriber2: {'sources': sources2,
328
328
'filter descriptions': [u'Special Filter!']}},
329
329
BugNotificationSet().getRecipientFilterData(
330
{self.subscriber: sources, subscriber2: sources2},
330
self.bug, {self.subscriber: sources, subscriber2: sources2},
331
331
[self.notification, notification2]))
333
333
def test_getRecipientFilterData_mute_one_filter_of_two(self):
343
343
{self.subscriber: {'sources': sources,
344
344
'filter descriptions': ['Another Filter!']}},
345
345
BugNotificationSet().getRecipientFilterData(
346
{self.subscriber: sources},
346
self.bug, {self.subscriber: sources},
347
347
[self.notification, self.notification2]))
349
349
def test_getRecipientFilterData_mute_both_filters_mutes(self):
362
362
self.assertEqual(
364
364
BugNotificationSet().getRecipientFilterData(
365
{self.subscriber: sources},
365
self.bug, {self.subscriber: sources},
366
366
[self.notification, self.notification2]))
368
def test_getRecipientFilterData_mute_bug_mutes(self):
369
# Mute the bug for the subscriber.
370
self.team = self.factory.makeTeam()
371
self.subscriber.join(self.team)
373
self.bug.mute(self.subscriber, self.subscriber)
374
sources = list(self.notification.recipients)
378
BugNotificationSet().getRecipientFilterData(
379
self.bug, {self.subscriber: sources}, [self.notification]))
381
def test_getRecipientFilterData_mute_bug_mutes_only_themselves(self):
382
# Mute the bug for the subscriber.
383
self.bug.mute(self.subscriber, self.subscriber)
385
# Notification for the other person still goes through.
386
person = self.factory.makePerson(name='other')
387
self.addNotificationRecipient(self.notification, person)
389
sources = list(self.notification.recipients)
393
{person: {'filter descriptions': [],
394
'sources': sources}},
395
BugNotificationSet().getRecipientFilterData(
396
self.bug, {self.subscriber: sources,
398
[self.notification]))
400
def test_getRecipientFilterData_mute_bug_mutes_filter(self):
401
# Mute the bug for the subscriber.
402
self.bug.mute(self.subscriber, self.subscriber)
403
self.includeFilterInNotification(description=u'Special Filter!')
404
sources = list(self.notification.recipients)
407
BugNotificationSet().getRecipientFilterData(
408
self.bug, {self.subscriber: sources}, [self.notification]))
369
411
class TestNotificationProcessingWithoutRecipients(TestCaseWithFactory):
370
412
"""Adding notificatons without any recipients does not cause any harm.
596
638
'filter descriptions': [],
597
639
'sources': [notification.recipients[1]]}},
598
640
BugNotificationSet().getRecipientFilterData(
599
642
{team.teamowner: [notification.recipients[0]],
600
643
team: [notification.recipients[1]]},