本文整理汇总了Python中patchwork.models.EmailConfirmation.date方法的典型用法代码示例。如果您正苦于以下问题:Python EmailConfirmation.date方法的具体用法?Python EmailConfirmation.date怎么用?Python EmailConfirmation.date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类patchwork.models.EmailConfirmation
的用法示例。
在下文中一共展示了EmailConfirmation.date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_patch_submitter_expiry
# 需要导入模块: from patchwork.models import EmailConfirmation [as 别名]
# 或者: from patchwork.models.EmailConfirmation import date [as 别名]
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)
示例2: register
# 需要导入模块: from patchwork.models import EmailConfirmation [as 别名]
# 或者: from patchwork.models.EmailConfirmation import date [as 别名]
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)
示例3: testPatchSubmitterExpiry
# 需要导入模块: from patchwork.models import EmailConfirmation [as 别名]
# 或者: from patchwork.models.EmailConfirmation import date [as 别名]
def testPatchSubmitterExpiry(self):
defaults.project.save()
defaults.patch_author_person.save()
# someone submits a patch...
patch = Patch(project=defaults.project,
msgid='[email protected]', 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)