コード例 #1
0
    def test_schedule_without_send_at_with_check_url_false_not_sent_delete(
            self, mock_requests, mock_Response):
        EmailKind.objects.create(name='my-test-email',
                                 language='es',
                                 template='Hello, world!',
                                 plain_template='Hello, world! soy antiguo',
                                 default_sender='*****@*****.**',
                                 default_recipients='*****@*****.**',
                                 default_subject='Email Test',
                                 default_reply_to='*****@*****.**')

        schedule(
            'my-test-email', 'es',
            {'check_url': 'http://service.qdqmedia.com/cansend/34324/blah'})

        mock_Response.configure_mock(status_code=200)
        mock_Response.configure_mock(text=json.dumps({
            'allowed': False,
            'delete': True
        }))
        mock_requests.get.return_value = mock_Response

        sent_count = send_entries()
        self.assertEqual(0, sent_count)
        entries = EmailEntry.objects.filter(deleted=True)
        self.assertEqual(1, len(entries))

        clean_entries()
        entries = EmailEntry.objects.filter(deleted=True)
        self.assertEqual(0, len(entries))
コード例 #2
0
    def test_send_emailkind_no_active(self):
        EmailKind.objects.create(name='my-test-email',
                                 language='es',
                                 template='Hello, world!',
                                 plain_template='Hello, world! soy antiguo',
                                 default_sender='*****@*****.**',
                                 default_recipients='*****@*****.**',
                                 default_subject='Email Test',
                                 default_reply_to='*****@*****.**',
                                 active=False)
        entry_params = {}
        entry = schedule('my-test-email', 'es', entry_params)
        send_entries()

        entry = EmailEntry.objects.get(id=entry.id)
        self.assertFalse(entry.sent)
        self.assertIsNone(entry.datetime_sent)
コード例 #3
0
 def test_send_with_specific_backend_success(self):
     EmailKind.objects.create(name='my-test-email',
                              language='es',
                              template='Hello, world!',
                              plain_template='Hello, world! soy antiguo',
                              default_sender='*****@*****.**',
                              default_recipients='*****@*****.**',
                              default_subject='Email Test',
                              default_reply_to='*****@*****.**')
     schedule('my-test-email', 'es', {'backend': 'mynewbackend'})
     sent_count = send_entries()
     self.assertEqual(1, sent_count)
コード例 #4
0
    def test_schedule_with_send_at_future_without_check_url_not_sent(self):
        EmailKind.objects.create(name='my-test-email',
                                 language='es',
                                 template='Hello, world!',
                                 plain_template='Hello, world! soy antiguo',
                                 default_sender='*****@*****.**',
                                 default_recipients='*****@*****.**',
                                 default_subject='Email Test',
                                 default_reply_to='*****@*****.**')

        now_ts = int(time.mktime(timezone.now().timetuple()))
        future_ts = now_ts + 300
        schedule('my-test-email', 'es', {'send_at': future_ts})
        sent_count = send_entries()
        self.assertEqual(0, sent_count)
コード例 #5
0
 def test_send_with_specific_backend_rejected(self):
     EmailKind.objects.create(name='my-test-email',
                              language='es',
                              template='Hello, world!',
                              plain_template='Hello, world! soy antiguo',
                              default_sender='*****@*****.**',
                              default_recipients='*****@*****.**',
                              default_subject='Email Test',
                              default_reply_to='*****@*****.**')
     entry = schedule('my-test-email', 'es', {'backend': 'myrejectbackend'})
     sent_count = send_entries()
     entry = EmailEntry.objects.get(id=entry.id)
     self.assertEqual(0, sent_count)
     self.assertFalse(entry.sent)
     self.assertEqual(entry.thirdparty_reject, 'potato')
コード例 #6
0
ファイル: send_emails.py プロジェクト: qdqmedia/leela
 def handle(self, *args, **options):
     while True:
         send_entries()
         time.sleep(settings.SENDER_ELLAPSED_SECONDS)