-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from incuna/validation-email-fix
Update TestRegisterView to check mail outbox
- Loading branch information
Showing
8 changed files
with
65 additions
and
55 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
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
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,20 +1,20 @@ | ||
from incuna_test_utils.testcases.urls import URLsTestCase | ||
from incuna_test_utils.testcases.urls import URLTestCase | ||
|
||
from .. import views | ||
|
||
|
||
class TestURLs(URLsTestCase): | ||
class TestURLs(URLTestCase): | ||
"""Ensure the urls work.""" | ||
|
||
def test_profile_avatar_url(self): | ||
self.check_url( | ||
view_class=views.ProfileAvatar, | ||
self.assert_url_matches_view( | ||
view=views.ProfileAvatar, | ||
expected_url='/profile/avatar', | ||
url_name='user_management_api:profile_avatar') | ||
|
||
def test_user_avatar_url(self): | ||
self.check_url( | ||
view_class=views.UserAvatar, | ||
self.assert_url_matches_view( | ||
view=views.UserAvatar, | ||
expected_url='/users/1/avatar', | ||
url_name='user_management_api:user_avatar', | ||
url_kwargs={'pk': 1}) |
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
10 changes: 10 additions & 0 deletions
10
user_management/api/templates/user_management/account_validation_email.txt
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% spaceless %}{% load i18n %}{% autoescape off %}{% blocktrans %} | ||
You are receiving this email because your email address has been used to | ||
register an account at {{ site.name }}. | ||
|
||
Please click the following link to complete your registration: | ||
{% endblocktrans %} | ||
http://{{ site.domain }}/#/register/verify/{{ uid }}/{{ token }}/ | ||
|
||
{% endautoescape %} | ||
{% endspaceless %} |
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,57 +1,57 @@ | ||
from incuna_test_utils.testcases.urls import URLsTestCase | ||
from incuna_test_utils.testcases.urls import URLTestCase | ||
|
||
from .. import views | ||
|
||
|
||
class TestURLs(URLsTestCase): | ||
class TestURLs(URLTestCase): | ||
"""Ensure the urls work.""" | ||
|
||
def test_auth_token_url(self): | ||
self.check_url( | ||
view_class=views.GetToken, | ||
self.assert_url_matches_view( | ||
view=views.GetToken, | ||
expected_url='/auth', | ||
url_name='user_management_api:auth') | ||
|
||
def test_password_reset_confirm_url(self): | ||
self.check_url( | ||
view_class=views.PasswordReset, | ||
self.assert_url_matches_view( | ||
view=views.PasswordReset, | ||
expected_url='/auth/password_reset/confirm/a/x-y', | ||
url_name='user_management_api:password_reset_confirm', | ||
url_kwargs={'uidb64': 'a', 'token': 'x-y'}) | ||
|
||
def test_password_reset_url(self): | ||
self.check_url( | ||
view_class=views.PasswordResetEmail, | ||
self.assert_url_matches_view( | ||
view=views.PasswordResetEmail, | ||
expected_url='/auth/password_reset', | ||
url_name='user_management_api:password_reset') | ||
|
||
def test_profile_detail_url(self): | ||
self.check_url( | ||
view_class=views.ProfileDetail, | ||
self.assert_url_matches_view( | ||
view=views.ProfileDetail, | ||
expected_url='/profile', | ||
url_name='user_management_api:profile_detail') | ||
|
||
def test_password_change_url(self): | ||
self.check_url( | ||
view_class=views.PasswordChange, | ||
self.assert_url_matches_view( | ||
view=views.PasswordChange, | ||
expected_url='/profile/password', | ||
url_name='user_management_api:password_change') | ||
|
||
def test_register_url(self): | ||
self.check_url( | ||
view_class=views.UserRegister, | ||
self.assert_url_matches_view( | ||
view=views.UserRegister, | ||
expected_url='/register', | ||
url_name='user_management_api:register') | ||
|
||
def test_user_detail_url(self): | ||
self.check_url( | ||
view_class=views.UserDetail, | ||
self.assert_url_matches_view( | ||
view=views.UserDetail, | ||
expected_url='/users/1', | ||
url_name='user_management_api:user_detail', | ||
url_kwargs={'pk': 1}) | ||
|
||
def test_user_list_url(self): | ||
self.check_url( | ||
view_class=views.UserList, | ||
self.assert_url_matches_view( | ||
view=views.UserList, | ||
expected_url='/users', | ||
url_name='user_management_api:user_list') |
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
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,29 +1,13 @@ | ||
from django.contrib.auth.models import AnonymousUser | ||
from django.test import TestCase | ||
from incuna_test_utils.testcases.request import RequestTestCase as RequestTestCaseBase | ||
from rest_framework.test import APIRequestFactory, force_authenticate | ||
from incuna_test_utils.compat import Python2AssertMixin | ||
from incuna_test_utils.testcases.api_request import BaseAPIRequestTestCase | ||
from incuna_test_utils.testcases.request import BaseRequestTestCase | ||
|
||
from .factories import UserFactory | ||
|
||
|
||
class APIRequestTestCase(TestCase): | ||
class APIRequestTestCase(Python2AssertMixin, BaseAPIRequestTestCase): | ||
user_factory = UserFactory | ||
|
||
def create_request(self, method='get', url='/', user=None, auth=True, **kwargs): | ||
if not user: | ||
if auth: | ||
user = self.user_factory.create() | ||
else: | ||
user = AnonymousUser() | ||
kwargs['format'] = 'json' | ||
request = getattr(APIRequestFactory(), method)(url, **kwargs) | ||
request.user = user | ||
if auth: | ||
force_authenticate(request, user) | ||
if 'data' in kwargs: | ||
request.DATA = kwargs['data'] | ||
return request | ||
|
||
|
||
class RequestTestCase(RequestTestCaseBase): | ||
class RequestTestCase(Python2AssertMixin, BaseRequestTestCase): | ||
user_factory = UserFactory |