Skip to content

Commit

Permalink
test for working password reset view
Browse files Browse the repository at this point in the history
  • Loading branch information
dasyad00 committed Jul 25, 2021
1 parent 6fd952a commit e19b2ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -3,7 +3,7 @@

{% translate "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'cosmos_users:password_reset_confirm' uidb64=uid token=token %}
<a href="{{ protocol }}://{{ domain }}{% url 'cosmos_users:password_reset_confirm' uidb64=uid token=token %}">{{ protocol }}://{{ domain }}{% url 'cosmos_users:password_reset_confirm' uidb64=uid token=token %}</a>
{% endblock %}
{% translate 'Your username, in case you’ve forgotten:' %} {{ user.get_username }}

Expand Down
18 changes: 18 additions & 0 deletions tests/user/views/password.py
@@ -1,3 +1,4 @@
from bs4 import BeautifulSoup
from django.contrib.auth.models import User
from django.core import mail
from django.test import TestCase
Expand All @@ -22,6 +23,23 @@ def assert_email_sent(self, recipient):
self.assertEqual(mail.outbox[0].to[0], exp_email_recipient)
self.assertEqual(mail.outbox[0].from_email, exp_email_sender)
self.assertEqual(mail.outbox[0].subject, exp_email_subject)
self.assert_working_password_reset_view()

def assert_working_password_reset_view(self):
# setup
html_parser = BeautifulSoup(mail.outbox[0].body, "html.parser")
link = html_parser.find("a")
link_url = link.get("href")

exp_status_code = 302
exp_url = "/accounts/reset/MQ/set-password/"

# act
response = self.client.get(link_url)

# test
self.assertEqual(exp_status_code, response.status_code)
self.assertEqual(exp_url, response.url)

def test_success(self):
# setup
Expand Down

0 comments on commit e19b2ba

Please sign in to comment.