Django Test framework with file based Email backend server

前端 未结 2 1574
难免孤独
难免孤独 2021-01-18 02:25

I have formulated test cases in Django framework.

Use Case: I am using API that register user by sending them an Email and when they click on the link provided in t

2条回答
  •  无人共我
    2021-01-18 03:19

    The simple answer:

    You can't do this without engineering your own email system, but that would probably be silly. I would suggest doing something else to verify that the code was successful without requiring the email to be sent. Like, run the code, assume the user clicks the link and create RequestFactory to get/post the link to run the view code associated with it.

    From the Django Testing Application:

    Email services

    "If any of your Django views send email using Django's email functionality,
    you probably don't want to send email each time you run a test using that
    view. For this reason, Django's test runner automatically redirects all
    Django-sent email to a dummy outbox. This lets you test every aspect of
    sending email -- from the number of messages sent to the contents of each
    message -- without actually sending the messages."
    

提交回复
热议问题