Ejemplo n.º 1
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.º 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 register(self, date):
        user = create_user()
        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()

        return (user, conf)
Ejemplo n.º 4
0
    def register(self, date):
        user = create_user()
        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()

        return (user, conf)
Ejemplo n.º 5
0
    def testPatchSubmitterExpiry(self):
        defaults.project.save()
        defaults.patch_author_person.save()

        # someone submits a patch...
        patch = Patch(project=defaults.project,
                      msgid='*****@*****.**',
                      name='test patch',
                      submitter=defaults.patch_author_person,
                      content=defaults.patch)
        patch.save()

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        userid = 'test-user'
        user = User.objects.create_user(userid,
                                        defaults.patch_author_person.email,
                                        userid)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        self.assertEqual(user.email, patch.submitter.email)

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

        # ... which expires
        do_expiry()

        # 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=defaults.patch_author_person.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=defaults.patch_author_person.pk).user, None)
Ejemplo n.º 6
0
    def testPatchSubmitterExpiry(self):
        defaults.project.save()
        defaults.patch_author_person.save()

        # someone submits a patch...
        patch = Patch(project=defaults.project,
                      msgid='*****@*****.**', name='test patch',
                      submitter=defaults.patch_author_person,
                      content=defaults.patch)
        patch.save()

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        userid = 'test-user'
        user = User.objects.create_user(
            userid,
            defaults.patch_author_person.email, userid)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        self.assertEqual(user.email, patch.submitter.email)

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

        # ... which expires
        do_expiry()

        # 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=defaults.patch_author_person.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=defaults.patch_author_person.pk).user, None)