Esempio n. 1
0
    def test_correct_bounces_created(self):
        """Test to ensure that bounces are correctly inserted"""
        # Delete any existing bounces
        Bounce.objects.all().delete()

        result = views.process_bounce(self.bounce, self.notification)

        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
        self.assertTrue(Bounce.objects.filter(
            sns_topic=('arn:aws:sns:us-east-1:250214102493:'
                       'Demo_App_Unsubscribes'),
            sns_messageid='f34c6922-c3a1-54a1-bd88-23f998b43978',
            mail_timestamp=clean_time('2012-06-19T01:05:45.000Z'),
            mail_id=('00000138111222aa-33322211-cccc-cccc-cccc-'
                     'ddddaaaa0680-000000'),
            mail_from='*****@*****.**',
            address='*****@*****.**',
            feedback_id=('000001378603176d-5a4b5ad9-6f30-4198-a8c3-'
                         'b1eb0c270a1d-000000'),
            feedback_timestamp=clean_time('2012-05-25T14:59:38.605-07:00'),
            hard=True,
            bounce_type='Permanent',
            bounce_subtype='General',
            reporting_mta='example.com',
            action='failed',
            status='5.0.0',
            diagnostic_code='smtp; 550 user unknown'
        ).exists())
Esempio n. 2
0
    def test_correct_bounces_created(self):
        """Test to ensure that bounces are correctly inserted"""
        # Delete any existing bounces
        Bounce.objects.all().delete()

        result = views.process_bounce(self.bounce, self.notification)

        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
        self.assertTrue(
            Bounce.objects.filter(
                sns_topic=('arn:aws:sns:us-east-1:250214102493:'
                           'Demo_App_Unsubscribes'),
                sns_messageid='f34c6922-c3a1-54a1-bd88-23f998b43978',
                mail_timestamp=clean_time('2012-06-19T01:05:45.000Z'),
                mail_id=('00000138111222aa-33322211-cccc-cccc-cccc-'
                         'ddddaaaa0680-000000'),
                mail_from='*****@*****.**',
                address='*****@*****.**',
                feedback_id=('000001378603176d-5a4b5ad9-6f30-4198-a8c3-'
                             'b1eb0c270a1d-000000'),
                feedback_timestamp=clean_time('2012-05-25T14:59:38.605-07:00'),
                hard=True,
                bounce_type='Permanent',
                bounce_subtype='General',
                reporting_mta='example.com',
                action='failed',
                status='5.0.0',
                diagnostic_code='smtp; 550 user unknown').exists())
Esempio n. 3
0
    def test_two_bounces_created(self):
        """Test that new bounces are added to the database"""
        original_count = Bounce.objects.count()
        result = views.process_bounce(self.bounce, self.notification)
        new_count = Bounce.objects.count()

        self.assertEqual(new_count, original_count + 2)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
Esempio n. 4
0
    def test_two_bounces_created(self):
        """Test that new bounces are added to the database"""
        original_count = Bounce.objects.count()
        result = views.process_bounce(self.bounce, self.notification)
        new_count = Bounce.objects.count()

        self.assertEqual(new_count, original_count + 2)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
Esempio n. 5
0
    def test_signals_sent(self):
        """Test that a bounce feedback signal was sent"""
        # pylint: disable=attribute-defined-outside-init, unused-variable
        self.signal_count = 0

        @receiver(signals.feedback)
        def _signal_receiver(sender, **kwargs):
            """Test signal receiver"""
            # pylint: disable=unused-argument
            self.signal_count += 1
            self.signal_notification = kwargs['notification']

        result = views.process_bounce(self.bounce, self.notification)

        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
        self.assertEqual(self.signal_count, 2)
        self.assertEqual(self.signal_notification, self.notification)
Esempio n. 6
0
    def test_signals_sent(self):
        """Test that a bounce feedback signal was sent"""
        # pylint: disable=attribute-defined-outside-init, unused-variable
        self.signal_count = 0

        @receiver(signals.feedback)
        def _signal_receiver(sender, **kwargs):
            """Test signal receiver"""
            # pylint: disable=unused-argument
            self.signal_count += 1
            self.signal_notification = kwargs['notification']

        result = views.process_bounce(self.bounce, self.notification)

        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.content.decode('ascii'), 'Bounce Processed')
        self.assertEqual(self.signal_count, 2)
        self.assertEqual(self.signal_notification, self.notification)