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_no_method_or_target(self): """ Test that the pigeon is processed correctly when there are no recipients """ # Then try to send custom news to Bob pigeonpost_queue.send(sender=self.moderated_news, render_email_method='email_moderators') process_queue() messages = Outbox.objects.all() self.assertEqual(len(messages),2)
def test_send_to_method(self): """ Test that we can send a pigeon to a specific user """ pigeonpost_queue.send(sender=self.news, render_email_method='email_news', send_to_method='get_everyone_called_bob') process_queue() messages = Outbox.objects.all() self.assertEqual(len(messages),1) self.assertEqual(messages[0].user, self.bob)
def test_no_recipients(self): """ Test that the pigeon is processed correctly when there are no recipients """ # Remove Bob User.objects.filter(username='******').delete() # Then try to send custom news to Bob pigeonpost_queue.send(sender=self.news, render_email_method='email_news', send_to_method='get_everyone_called_bob') process_queue() messages = Outbox.objects.all() self.assertEqual(len(messages),0) pigeon = Pigeon.objects.get(source_id=self.news.id) self.assertEqual(pigeon.to_send, False)
def test_resend_pigeon(self): process_queue(force=True) self.assertEqual(Outbox.objects.count(), 2) self.assertEqual(Outbox.objects.filter(user__username='******').count(), 0) # Now another user signs up chelsea = Profile.objects.get(user__username='******') chelsea.subscribed_to_news = True chelsea.save() # And we resend the pigeon pigeonpost_queue.send(sender=self.message, retry=True) process_queue(force=True) # And chelsea gets a message self.assertEqual(Outbox.objects.count(), 3) self.assertEqual(Outbox.objects.filter(user__username='******').count(), 1)
def test_many_signals_one_pigeon(self): pigeonpost_queue.send(sender=self.message, defer_for=1000) pigeonpost_queue.send(sender=self.message, defer_for=1000) pigeonpost_queue.send(sender=self.message, defer_for=1000) self.assertEqual(Pigeon.objects.count(), 1) pigeonpost_queue.send(sender=self.message) process_queue() pigeonpost_queue.send(sender=self.message) process_queue() pigeonpost_queue.send(sender=self.message) process_queue() self.assertEqual(Pigeon.objects.count(), 1)
def _send_now(self): pigeonpost_queue.send(sender=self.message) # send now process_queue() self.pigeon = Pigeon.objects.get(id=self.pigeon.id)
def setUp(self): self.users, self.staff, _, _ = create_fixtures(create_message=False) ModeratedNews(subject='...', body='...', published=True).save() process_queue()
def deploy_pigeons(): """ This version of deploy doesn't get blocked by a pid file """ process_queue() process_outbox()