Beispiel #1
0
    def test_batch_mailer(self):
        prefs = UserActivity.objects.get(user=self.bobby)
        prefs.notification_preference = 'S'
        prefs.save()

        layer = Layer.objects.create(owner=self.bobby, name='layer1',typename='layer1')
        comment_on(layer, self.admin, "This is great")
        comment_on(layer, self.admin, "This is great")

        messages = []
        def handle(self, record):
            messages.append(record)
        handler = type('handler', (logging.Handler,), {'handle':handle})()
        handler.setLevel(logging.INFO)
        logger = logging.getLogger("mapstory.social_signals")
        logger.addHandler(handler)

        social_signals.batch_notification()

        self.assertEqual('2', re.search('\d', messages[0].getMessage()).group())

        action = prefs.other_actor_actions.all()[0]
        action.timestamp = action.timestamp - timedelta(days = 1)
        action.save()

        social_signals.batch_notification()
        self.assertEqual('1', re.search('\d', messages[1].getMessage()).group())

        logger.removeHandler(handler)
Beispiel #2
0
    def test_batch_mailer(self):
        prefs = UserActivity.objects.get(user=self.bobby)
        prefs.notification_preference = 'S'
        prefs.save()

        layer = Layer.objects.create(owner=self.bobby,
                                     name='layer1',
                                     typename='layer1')
        comment_on(layer, self.admin, "This is great")
        comment_on(layer, self.admin, "This is great")

        messages = []

        def handle(self, record):
            messages.append(record)

        handler = type('handler', (logging.Handler, ), {'handle': handle})()
        handler.setLevel(logging.INFO)
        logger = logging.getLogger("mapstory.social_signals")
        logger.addHandler(handler)

        social_signals.batch_notification()

        self.assertEqual('2',
                         re.search('\d', messages[0].getMessage()).group())

        action = prefs.other_actor_actions.all()[0]
        action.timestamp = action.timestamp - timedelta(days=1)
        action.save()

        social_signals.batch_notification()
        self.assertEqual('1',
                         re.search('\d', messages[1].getMessage()).group())

        logger.removeHandler(handler)
 def handle(self, *args, **opts):
     batch_notification()
 def handle(self, *args, **opts):
     batch_notification()