集成测试Django All-Auth电子邮件确认

时间:2015-11-05 16:55:47

标签: django email selenium tdd django-allauth

我想进行一些集成测试,而且我仍然会考虑如何测试注册过程中的电子邮件确认位。

我的用户故事(基本上)是新访问者访问该网站,决定他们想要注册,确认他们的电子邮件地址,然后重定向到他们闪亮的新个人资料。

如何模拟点击电子邮件中的链接以重定向到用户个人资料?

我目前正在使用Selenium进行功能/集成测试,并在某种程度上使用django测试套件。

2 个答案:

答案 0 :(得分:1)

这两个文档页面包含您需要的所有内容:

一个简单的例子:

from django.test import TestCase
from django.core import mail

class EmailTestCase(TestCase):
    def setUp(self):
        ## Do something
        pass

    def test_email_content(self):
        ## Do something that triggers an email.
        ## Check the number of emails.
        print(len(mail.outbox))
        ## Check the content of the first email.
        first_email = mail.outbox[0]
        if first_email:
            print(first_email.body)

答案 1 :(得分:0)

你应该以python的方式阅读电子邮件。

步骤:

  1. 查找电子邮件
  2. 存储链接
  3. 启动您的硒测试,并打开所述链接
  4. 确认您在页面上
相关问题