Skip to content

Commit

Permalink
Refactor: using shallow_merge_dicts in register view tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apragacz committed Mar 28, 2019
1 parent 1516ac9 commit 31d8960
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions tests/api/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from rest_registration.api.views.register import RegisterSigner
from rest_registration.settings import registration_settings
from tests.utils import shallow_merge_dicts

from .base import APIViewTestCase

Expand All @@ -19,20 +20,6 @@
'VERIFICATION_FROM_EMAIL': VERIFICATION_FROM_EMAIL,
}

REST_REGISTRATION_WITH_VERIFICATION_AUTO_LOGIN = {
'REGISTER_VERIFICATION_ENABLED': True,
'REGISTER_VERIFICATION_URL': REGISTER_VERIFICATION_URL,
'VERIFICATION_FROM_EMAIL': VERIFICATION_FROM_EMAIL,
'REGISTER_VERIFICATION_AUTO_LOGIN': True,
}

REST_REGISTRATION_WITH_VERIFICATION_NO_PASSWORD = {
'REGISTER_VERIFICATION_ENABLED': True,
'REGISTER_VERIFICATION_URL': REGISTER_VERIFICATION_URL,
'VERIFICATION_FROM_EMAIL': VERIFICATION_FROM_EMAIL,
'REGISTER_SERIALIZER_PASSWORD_CONFIRM': False,
}

REST_REGISTRATION_WITHOUT_VERIFICATION = {
'REGISTER_VERIFICATION_ENABLED': False,
}
Expand Down Expand Up @@ -63,7 +50,11 @@ def test_register_serializer_ok(self):
)

@override_settings(
REST_REGISTRATION=REST_REGISTRATION_WITH_VERIFICATION_NO_PASSWORD,
REST_REGISTRATION=shallow_merge_dicts(
REST_REGISTRATION_WITH_VERIFICATION, {
'REGISTER_SERIALIZER_PASSWORD_CONFIRM': False,
},
),
)
def test_register_serializer_no_password_ok(self):
serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS
Expand Down Expand Up @@ -145,7 +136,11 @@ def test_register_with_html_email_ok(self):
signer.verify()

@override_settings(
REST_REGISTRATION=REST_REGISTRATION_WITH_VERIFICATION_NO_PASSWORD,
REST_REGISTRATION=shallow_merge_dicts(
REST_REGISTRATION_WITH_VERIFICATION, {
'REGISTER_SERIALIZER_PASSWORD_CONFIRM': False,
},
),
)
def test_register_no_password_confirm_ok(self):
data = self._get_register_user_data(password='testpassword')
Expand Down Expand Up @@ -291,7 +286,11 @@ def test_verify_ok(self):
self.assertTrue(user.is_active)

@override_settings(
REST_REGISTRATION=REST_REGISTRATION_WITH_VERIFICATION_AUTO_LOGIN,
REST_REGISTRATION=shallow_merge_dicts(
REST_REGISTRATION_WITH_VERIFICATION, {
'REGISTER_VERIFICATION_AUTO_LOGIN': True,
},
),
)
def test_verify_ok_login(self):
with patch('django.contrib.auth.login') as login_mock:
Expand Down

0 comments on commit 31d8960

Please sign in to comment.