def test_if_unsubscriber_link_is_removed_by_trickery_message_refuses_to_send(self): self.assertEquals(len(mail.outbox), 0) self.create_subscribed_person() Factory.message() n = self.newsletter n.unsubscribe_footer = "" n.save() self.send_newsletter_message() self.assertEquals(len(mail.outbox), 0)
def send_test_message(self): self.test_message = Factory.message() self.subject = self.test_message.subject self.body_unrendered = self.test_message.body_text_unrendered queue_message(message=self.test_message, subscription=self.subscription) om = OutgoingMessage.objects.get( person=self.person, message=self.test_message, ) self.body = om.render_email_string( self.test_message.body_text_unrendered) process_outgoing_message_queue()
def send_test_transactional_message(self): self.transactional_message = Factory.message(person=self.person, transactional=True) self.subject = self.transactional_message.subject self.body = self.transactional_message.body_text_unrendered self.body_unrendered = self.transactional_message.body_text_unrendered queue_transactional_message(message=self.transactional_message, person=self.person) om = OutgoingMessage.objects.get( person=self.person, message=self.transactional_message, ) self.body = om.render_email_string( self.transactional_message.body_text_unrendered, plain_text=True) process_outgoing_message_queue()
def test_hard_bounce_stores_event_in_archive(self): s = Factory.subscription() p = s.person m = Factory.message() bounce_reason = Factory.rand_text() p.hard_bounce(reason=bounce_reason, message=m) self.assertEquals(HistoricalEvent.objects.count(), 1) h = HistoricalEvent.objects.all()[0] self.assertEquals(h.event_type, "hard_bounce") self.assertEquals(h.event_creator_type, "person") self.assertEquals(h.event_creator_pk, p.pk) self.assertEquals(h.event_creator_data, { "person": p.get_data_dict(), "reason": bounce_reason, "message": m.get_data_dict(), })
def test_send_messsage_does_not_send_to_hard_bounce(self): self.subscription.double_opt_in() m = Factory.message() self.person.hard_bounce(bouncing_message=m) self.send_test_message() self.assertEquals(len(mail.outbox), 0)
def test_send_transactional_message_does_not_send_to_hard_bounce(self): m = Factory.message() self.person.hard_bounce(bouncing_message=m) self.send_test_transactional_message() self.assertEquals(len(mail.outbox), 0)