コード例 #1
0
 def fire(self, **kwargs):
     parent_events = [
         EditDocumentInTreeEvent(doc)
         for doc in self.revision.document.get_topic_parents()
     ]
     return EventUnion(self,
                       EditDocumentInTreeEvent(self.revision.document),
                       *parent_events).fire(**kwargs)
    def test_merging(self):
        """Test that duplicate emails across multiple events get merged."""
        watch(event_type=TYPE, email='*****@*****.**').save()
        watch(event_type=TYPE, email='*****@*****.**').save()
        registered_user = user(email='*****@*****.**', save=True)
        watch(event_type=ANOTHER_TYPE, user=registered_user).save()

        self._emails_eq(['*****@*****.**', '*****@*****.**'],
                        EventUnion(SimpleEvent(), AnotherEvent()))
コード例 #3
0
ファイル: test_events.py プロジェクト: mozilla/django-tidings
 def test_fire(self):
     """Assert firing the union gets the mails from the first event."""
     global fire_simple_event_called
     watch(event_type=TYPE, email='*****@*****.**').save()
     simple_event = FireSimpleEvent()
     fire_simple_event_called = False
     another_event = AnotherEvent()
     EventUnion(simple_event, another_event).fire()
     self.assertTrue(fire_simple_event_called)
    def test_fire(self):
        """Assert firing the union gets the mails from the first event."""
        class FireSimpleEvent(SimpleEvent):
            called = False

            def _mails(self, users_and_watches):
                self.called = True
                return []

        watch(event_type=TYPE, email='*****@*****.**').save()
        simple_event = FireSimpleEvent()
        another_event = AnotherEvent()
        EventUnion(simple_event, another_event).fire()
        self.assertTrue(simple_event.called)
    def test_duplicates_case_insensitive(self):
        """Test that duplicate merging is case insensitive."""

        # These mocks return their users in descending order like the SQL
        # query.
        class OneEvent(object):
            def _users_watching(self):
                return [(user(email='*****@*****.**'), [watch()])]

        class AnotherEvent(object):
            def _users_watching(self):
                return [(user(email='*****@*****.**'), [watch()]),
                        (user(email='*****@*****.**'), [watch()])]

        addresses = [
            u.email for u, w in EventUnion(OneEvent(),
                                           AnotherEvent())._users_watching()
        ]

        self.assertEqual(2, len(addresses))
        self.assertEqual('*****@*****.**', addresses[0].lower())
コード例 #6
0
ファイル: events.py プロジェクト: bituka/kitsune
 def fire(self, **kwargs):
     """Notify not only watchers of this thread but of the parent forum."""
     return EventUnion(self, NewThreadEvent(self.reply)).fire(**kwargs)
コード例 #7
0
ファイル: events.py プロジェクト: pirateyporat/kitsune
 def fire(self, **kwargs):
     """Notify watches of the document and of the locale."""
     return EventUnion(self, NewThreadEvent(self.post),
                       NewThreadInLocaleEvent(self.post)).fire(**kwargs)
コード例 #8
0
ファイル: events.py プロジェクト: pirateyporat/kitsune
 def fire(self, **kwargs):
     """Notify watchers of this thread, of the document, and of the
     locale."""
     return EventUnion(self, NewThreadEvent(self.reply),
                       NewPostInLocaleEvent(self.reply)).fire(**kwargs)
 def test_watch_lists(self):
     """Ensure the Union returns every watch a user has."""
     w1 = watch(event_type=TYPE, email='*****@*****.**', save=True)
     w2 = watch(event_type=TYPE, email='*****@*****.**', save=True)
     u, w = list(EventUnion(SimpleEvent())._users_watching())[0]
     self.assertEqual([w1, w2], sorted(w, key=lambda x: x.id))