Ejemplo n.º 1
0
    def handle(self, *args, **kwargs):
        errors = send_notifications()
        for (recipient, error) in errors:
            self.stderr.write("Failed sending to %s: %s" %
                              (recipient.email, error))

        expire_notifications()
Ejemplo n.º 2
0
    def test_patch_submitter_expiry(self):
        # someone submits a patch...
        patch = create_patch()
        submitter = patch.submitter

        # ... then starts registration...
        date = ((datetime.datetime.utcnow() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        user = create_user(link_person=False, email=submitter.email)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        conf = EmailConfirmation(type='registration', user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        expire_notifications()

        # we should see no matching user
        self.assertFalse(User.objects.filter(email=patch.submitter.email)
                         .exists())
        # but the patch and person should still be present
        self.assertTrue(Person.objects.filter(pk=submitter.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())
        # and there should be no user associated with the person
        self.assertEqual(Person.objects.get(pk=submitter.pk).user, None)
Ejemplo n.º 3
0
    def test_patch_submitter_expiry(self):
        # someone submits a patch...
        patch = create_patch()
        submitter = patch.submitter

        # ... then starts registration...
        date = ((datetime.datetime.utcnow() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        user = create_user(link_person=False, email=submitter.email)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        conf = EmailConfirmation(type='registration',
                                 user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        expire_notifications()

        # we should see no matching user
        self.assertFalse(
            User.objects.filter(email=patch.submitter.email).exists())
        # but the patch and person should still be present
        self.assertTrue(Person.objects.filter(pk=submitter.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())
        # and there should be no user associated with the person
        self.assertEqual(Person.objects.get(pk=submitter.pk).user, None)
Ejemplo n.º 4
0
    def test_recent_registration_expiry(self):
        date = (datetime.datetime.now() - EmailConfirmation.validity) + datetime.timedelta(hours=1)
        user, conf = self.register(date)

        expire_notifications()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertTrue(EmailConfirmation.objects.filter(pk=conf.pk).exists())
Ejemplo n.º 5
0
    def test_recent_registration_expiry(self):
        date = ((datetime.datetime.utcnow() - EmailConfirmation.validity) +
                datetime.timedelta(hours=1))
        user, conf = self.register(date)

        expire_notifications()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertTrue(EmailConfirmation.objects.filter(pk=conf.pk).exists())
Ejemplo n.º 6
0
    def test_inactive_registration_expiry(self):
        user, conf = self.register(datetime.datetime.now())

        # confirm registration
        conf.user.is_active = True
        conf.user.save()
        conf.deactivate()

        expire_notifications()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertFalse(EmailConfirmation.objects.filter(pk=conf.pk).exists())
Ejemplo n.º 7
0
    def test_inactive_registration_expiry(self):
        user, conf = self.register(datetime.datetime.utcnow())

        # confirm registration
        conf.user.is_active = True
        conf.user.save()
        conf.deactivate()

        expire_notifications()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertFalse(EmailConfirmation.objects.filter(pk=conf.pk).exists())