-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add additional email gui (wip) (#874)
- Loading branch information
Showing
4 changed files
with
151 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
# Projectroles dependency | ||
from projectroles.forms import SETTING_DISABLE_LABEL | ||
from projectroles.models import SODAR_CONSTANTS | ||
from projectroles.tests.test_models import SODARUserAdditionalEmailMixin | ||
from projectroles.tests.test_ui import UITestBase | ||
|
||
|
||
|
@@ -17,20 +18,54 @@ | |
|
||
|
||
@override_settings(AUTH_LDAP_USERNAME_DOMAIN='EXAMPLE') | ||
class TestUserDetails(UITestBase): | ||
class TestUserDetails(SODARUserAdditionalEmailMixin, UITestBase): | ||
"""Tests for user details page""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
# Create users | ||
self.local_user = self.make_user('local_user', False) | ||
self.ldap_user = self.make_user('user@EXAMPLE', False) | ||
self.url = reverse('userprofile:detail') | ||
|
||
def test_update_button(self): | ||
"""Test existence of user update button""" | ||
url = reverse('userprofile:detail') | ||
expected = [(self.local_user, 1), (self.ldap_user, 0)] | ||
self.assert_element_count(expected, url, 'sodar-user-btn-update') | ||
self.assert_element_count(expected, self.url, 'sodar-user-btn-update') | ||
|
||
def test_add_email_unset(self): | ||
"""Test existence of additional email elements without email""" | ||
self.assert_element_count( | ||
[(self.local_user, 0)], | ||
self.url, | ||
'sodar-user-email-table-row', | ||
'class', | ||
) | ||
self.assert_element_exists( | ||
[self.local_user], | ||
self.url, | ||
'sodar-user-email-table-not-found', | ||
True, | ||
) | ||
|
||
def test_add_email_set(self): | ||
"""Test existence of additional email elements with email""" | ||
self.make_email(self.local_user, '[email protected]') | ||
self.make_email(self.local_user, '[email protected]', verified=False) | ||
# Another user, should not be visible | ||
self.make_email(self.ldap_user, '[email protected]') | ||
self.assert_element_count( | ||
[(self.local_user, 2)], | ||
self.url, | ||
'sodar-user-email-table-row', | ||
'class', | ||
) | ||
self.assert_element_exists( | ||
[self.local_user], | ||
self.url, | ||
'sodar-user-email-table-not-found', | ||
False, | ||
) | ||
|
||
|
||
class TestUserSettings(UITestBase): | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,11 @@ | |
|
||
# Projectroles dependency | ||
from projectroles.app_settings import AppSettingAPI | ||
from projectroles.tests.test_models import EXAMPLE_APP_NAME, AppSettingMixin | ||
from projectroles.tests.test_models import ( | ||
EXAMPLE_APP_NAME, | ||
AppSettingMixin, | ||
SODARUserAdditionalEmailMixin, | ||
) | ||
from projectroles.views import MSG_FORM_INVALID | ||
|
||
from userprofile.views import SETTING_UPDATE_MSG | ||
|
@@ -36,7 +40,7 @@ def setUp(self): | |
# View tests ------------------------------------------------------------------- | ||
|
||
|
||
class TestUserDetailView(UserViewTestBase): | ||
class TestUserDetailView(SODARUserAdditionalEmailMixin, UserViewTestBase): | ||
"""Tests for UserDetailView""" | ||
|
||
def test_get(self): | ||
|
@@ -45,6 +49,17 @@ def test_get(self): | |
response = self.client.get(reverse('userprofile:detail')) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIsNotNone(response.context['user_settings']) | ||
self.assertEqual(response.context['add_emails'].count(), 0) | ||
|
||
def test_get_additional_email(self): | ||
"""Test GET with additional email""" | ||
self.make_email(self.user, '[email protected]') | ||
self.make_email(self.user, '[email protected]', verified=False) | ||
with self.login(self.user): | ||
response = self.client.get(reverse('userprofile:detail')) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIsNotNone(response.context['user_settings']) | ||
self.assertEqual(response.context['add_emails'].count(), 2) | ||
|
||
|
||
class TestUserSettingsView(AppSettingMixin, UserViewTestBase): | ||
|
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