-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #984 -- Add resetting user to template context
- Loading branch information
1 parent
4cba99a
commit 3c9a920
Showing
4 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import datetime | ||
from django.test import TestCase | ||
from django.core import mail | ||
from django.contrib.auth.tokens import default_token_generator | ||
from skivvy import ViewTestCase | ||
|
||
from accounts.tests.factories import UserFactory | ||
from core.tests.utils.cases import UserTestCase | ||
|
||
from allauth.account.models import EmailConfirmation, EmailAddress | ||
from allauth.account.forms import ResetPasswordKeyForm | ||
from allauth.account.utils import user_pk_to_url_str | ||
|
||
from ..views.default import AccountProfile, AccountLogin, ConfirmEmail | ||
from ..views import default | ||
from ..forms import ProfileForm | ||
|
||
|
||
class ProfileTest(ViewTestCase, UserTestCase, TestCase): | ||
view_class = AccountProfile | ||
view_class = default.AccountProfile | ||
template = 'accounts/profile.html' | ||
|
||
def setup_template_context(self): | ||
|
@@ -66,7 +69,7 @@ def test_update_profile_duplicate_email(self): | |
|
||
|
||
class LoginTest(ViewTestCase, UserTestCase, TestCase): | ||
view_class = AccountLogin | ||
view_class = default.AccountLogin | ||
|
||
def setup_models(self): | ||
self.user = UserFactory.create(username='imagine71', | ||
|
@@ -93,7 +96,7 @@ def test_successful_login_with_unverified_user(self): | |
|
||
|
||
class ConfirmEmailTest(ViewTestCase, UserTestCase, TestCase): | ||
view_class = ConfirmEmail | ||
view_class = default.ConfirmEmail | ||
url_kwargs = {'key': '123'} | ||
|
||
def setup_models(self): | ||
|
@@ -132,3 +135,30 @@ def test_activate_with_invalid_token(self): | |
|
||
self.email_address.refresh_from_db() | ||
assert self.email_address.verified is False | ||
|
||
|
||
class PasswordResetFromKeyViewTest(ViewTestCase, UserTestCase, TestCase): | ||
view_class = default.PasswordResetFromKeyView | ||
template = 'account/password_reset_from_key.html' | ||
|
||
def setup_models(self): | ||
self.user = UserFactory.create(email='[email protected]') | ||
|
||
def setup_template_context(self): | ||
return { | ||
'reset_user': self.user, | ||
'form': ResetPasswordKeyForm( | ||
user=self.user, | ||
temp_key=default_token_generator.make_token(self.user)) | ||
} | ||
|
||
def setup_url_kwargs(self): | ||
return { | ||
'uidb36': user_pk_to_url_str(self.user), | ||
'key': default_token_generator.make_token(self.user) | ||
} | ||
|
||
def test_render_view(self): | ||
response = self.request() | ||
assert response.status_code == 200 | ||
assert response.content == self.expected_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters