Exemplo n.º 1
0
class TestUnboundPigeons(TestCase):

    def setUp(self):
        self.users, self.staff, _, _ = create_fixtures(create_message=False)
        self.news = AggregateNews(news_bit='Bob is a great guy.')
        self.news.save()
        self.bob = User.objects.get(first_name__iexact='bob')

    def test_send(self):
        pigeonpost_queue.send(sender=AggregateNews, send_to=self.bob)
        process_queue()

        messages = Outbox.objects.all()
        self.assertEqual(len(messages),1)
        self.assertEqual(messages[0].user, self.bob)

    def test_double_send(self):
        pigeonpost_queue.send(sender=AggregateNews, send_to=self.bob)
        process_queue()

        messages = Outbox.objects.all()
        self.assertEqual(len(messages),1)
        self.assertEqual(messages[0].user, self.bob)

        pigeonpost_queue.send(sender=AggregateNews, send_to=self.bob)
        process_queue()

        messages = Outbox.objects.all()
        self.assertEqual(len(messages),2)
        self.assertEqual(messages[1].user, self.bob)
Exemplo n.º 2
0
 def setUp(self):
     self.users, self.staff, _, _ = create_fixtures(create_message=False)
     self.news = AggregateNews(news_bit='Bob is a great guy.')
     self.news.save()
     self.bob = User.objects.get(first_name__iexact='bob')