def testSendMassEmailsCommand(self): massemail1 = MassEmail(subject='Test Email1', body='<p>Some content1...</p>', created_by=self.u, lang='pl', mobile_platform='iphone') massemail1.save() massemail2 = MassEmail(subject='Test Email2', body='<p>Some content2...</p>', created_by=self.u, lang='pl', mobile_platform='iphone') massemail2.save() self.assertEqual( MassEmail.objects.filter(is_processed=False).count(), 2) call_command('send_massemails') self.assertEqual( MassEmail.objects.filter(is_processed=False).count(), 0) self.assertEqual(len(mail.outbox), 4)
def test_send_massemail_mobile( self ): massemail = MassEmail( subject='Test Email', body='<p>Some content...</p>', created_by=self.u, lang='pl', mobile_platform='iphone' ) massemail.save() sendMassEmail( massemail ) massemail = MassEmail.objects.get( pk=massemail.pk ) self.assertEqual( len( mail.outbox ), 2 ) self.assertEqual( massemail.sent_failed, 0 ) self.assertEqual( massemail.sent_correctly, 2 ) self.assertEqual( massemail.sent_failed_to, None ) self.assertSentCorrectly( massemail.sent_correctly_to, '[email protected];[email protected]' )
def test_send_massemail_mobile(self): massemail = MassEmail(subject='Test Email', body='<p>Some content...</p>', created_by=self.u, lang='pl', mobile_platform='iphone') massemail.save() sendMassEmail(massemail) massemail = MassEmail.objects.get(pk=massemail.pk) self.assertEqual(len(mail.outbox), 2) self.assertEqual(massemail.sent_failed, 0) self.assertEqual(massemail.sent_correctly, 2) self.assertEqual(massemail.sent_failed_to, None) self.assertSentCorrectly(massemail.sent_correctly_to, '[email protected];[email protected]')
def test_send_massemail(self): massemail = MassEmail(subject='Test Email', body='<p>Some content...</p>', created_by=self.u, lang='en') massemail.save() sendMassEmail(massemail) self.assertEqual(Profile.objects.count(), 7) massemail = MassEmail.objects.get(pk=massemail.pk) self.assertEqual(len(mail.outbox), 2) self.assertEqual(massemail.body, mail.outbox[0].body) self.assertEqual(massemail.subject, mail.outbox[0].subject) self.assertEqual(massemail.sent_failed, 0) self.assertEqual(massemail.sent_correctly, 2) self.assertEqual(massemail.sent_failed_to, None) self.assertSentCorrectly(massemail.sent_correctly_to, '[email protected];[email protected]') mail.outbox = [] massemail.is_processed = False massemail.sent_correctly_to = '*****@*****.**' massemail.save() sendMassEmail(massemail) self.assertEqual(len(mail.outbox), 1) self.assertTrue('*****@*****.**' in mail.outbox[0].recipients()) massemail = MassEmail.objects.get(pk=massemail.pk) self.assertEqual(massemail.sent_failed, 0) self.assertEqual(massemail.sent_correctly, 2) self.assertEqual(massemail.sent_failed_to, None) self.assertSentCorrectly(massemail.sent_correctly_to, '[email protected];[email protected]')
def testSendMassEmailsCommand( self ): massemail1 = MassEmail( subject='Test Email1', body='<p>Some content1...</p>', created_by=self.u, lang='pl', mobile_platform='iphone' ) massemail1.save() massemail2 = MassEmail( subject='Test Email2', body='<p>Some content2...</p>', created_by=self.u, lang='pl', mobile_platform='iphone' ) massemail2.save() self.assertEqual( MassEmail.objects.filter( is_processed=False ).count(), 2 ) call_command( 'send_massemails' ) self.assertEqual( MassEmail.objects.filter( is_processed=False ).count(), 0 ) self.assertEqual( len( mail.outbox ), 4 )
def test_send_massemail( self ): massemail = MassEmail( subject='Test Email', body='<p>Some content...</p>', created_by=self.u, lang='en' ) massemail.save() sendMassEmail( massemail ) self.assertEqual( Profile.objects.count(), 7 ) massemail = MassEmail.objects.get( pk=massemail.pk ) self.assertEqual( len( mail.outbox ), 2 ) self.assertEqual( massemail.body, mail.outbox[0].body ) self.assertEqual( massemail.subject, mail.outbox[0].subject ) self.assertEqual( massemail.sent_failed, 0 ) self.assertEqual( massemail.sent_correctly, 2 ) self.assertEqual( massemail.sent_failed_to, None ) self.assertSentCorrectly( massemail.sent_correctly_to, '[email protected];[email protected]' ) mail.outbox = [] massemail.is_processed = False massemail.sent_correctly_to = '*****@*****.**' massemail.save() sendMassEmail( massemail ) self.assertEqual( len( mail.outbox ), 1 ) self.assertTrue( '*****@*****.**' in mail.outbox[0].recipients() ) massemail = MassEmail.objects.get( pk=massemail.pk ) self.assertEqual( massemail.sent_failed, 0 ) self.assertEqual( massemail.sent_correctly, 2 ) self.assertEqual( massemail.sent_failed_to, None ) self.assertSentCorrectly( massemail.sent_correctly_to, '[email protected];[email protected]' )