-
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.
- Loading branch information
Showing
2 changed files
with
132 additions
and
48 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 |
---|---|---|
|
@@ -7,19 +7,23 @@ | |
from selenium.webdriver.support.ui import WebDriverWait | ||
|
||
# Projectroles dependency | ||
from projectroles.app_settings import AppSettingAPI | ||
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 | ||
|
||
|
||
app_settings = AppSettingAPI() | ||
|
||
|
||
# SODAR constants | ||
SITE_MODE_TARGET = SODAR_CONSTANTS['SITE_MODE_TARGET'] | ||
|
||
|
||
@override_settings(AUTH_LDAP_USERNAME_DOMAIN='EXAMPLE') | ||
class TestUserDetails(SODARUserAdditionalEmailMixin, UITestBase): | ||
"""Tests for user details page""" | ||
class TestUserDetailView(SODARUserAdditionalEmailMixin, UITestBase): | ||
"""Tests for UserDetailView""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
|
@@ -33,14 +37,56 @@ def test_update_button(self): | |
expected = [(self.local_user, 1), (self.ldap_user, 0)] | ||
self.assert_element_count(expected, self.url, 'sodar-user-btn-update') | ||
|
||
def test_update_button_read_only(self): | ||
"""Test existence of user update button with site read-only mode""" | ||
app_settings.set('projectroles', 'site_read_only', True) | ||
expected = [(self.local_user, 0), (self.ldap_user, 0)] | ||
self.assert_element_count(expected, self.url, 'sodar-user-btn-update') | ||
|
||
def test_settings_button(self): | ||
"""Test existence of settings update button""" | ||
expected = [ | ||
(self.superuser, 1), | ||
(self.local_user, 1), | ||
(self.ldap_user, 1), | ||
] | ||
self.assert_element_count(expected, self.url, 'sodar-user-btn-settings') | ||
|
||
def test_settings_button_read_only(self): | ||
"""Test existence of settings update button with site read-only mode""" | ||
app_settings.set('projectroles', 'site_read_only', True) | ||
expected = [ | ||
(self.superuser, 1), | ||
(self.local_user, 0), | ||
(self.ldap_user, 0), | ||
] | ||
self.assert_element_count(expected, self.url, 'sodar-user-btn-settings') | ||
|
||
def test_add_email_button(self): | ||
"""Test existence of add email button""" | ||
expected = [ | ||
(self.superuser, 1), | ||
(self.local_user, 1), | ||
(self.ldap_user, 1), | ||
] | ||
self.assert_element_count( | ||
expected, self.url, 'sodar-user-btn-email-add' | ||
) | ||
|
||
def test_add_email_button_read_only(self): | ||
"""Test existence of add email button with site read-only mode""" | ||
app_settings.set('projectroles', 'site_read_only', True) | ||
expected = [ | ||
(self.superuser, 1), | ||
(self.local_user, 0), | ||
(self.ldap_user, 0), | ||
] | ||
self.assert_element_count( | ||
expected, self.url, 'sodar-user-btn-email-add' | ||
) | ||
|
||
def test_additional_email_unset(self): | ||
"""Test existence of additional email elements without email""" | ||
self.assert_element_exists( | ||
[self.local_user], | ||
self.url, | ||
'sodar-user-btn-email-add', | ||
True, | ||
) | ||
self.assert_element_count( | ||
[(self.local_user, 0)], | ||
self.url, | ||
|
@@ -66,12 +112,6 @@ def test_additional_email_set(self): | |
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_exists( | ||
[self.local_user], | ||
self.url, | ||
'sodar-user-btn-email-add', | ||
True, | ||
) | ||
self.assert_element_count( | ||
[(self.local_user, 2)], | ||
self.url, | ||
|
@@ -91,6 +131,42 @@ def test_additional_email_set(self): | |
False, | ||
) | ||
|
||
def test_additional_email_set_read_only(self): | ||
"""Test additional email with site read-only mode""" | ||
app_settings.set('projectroles', 'site_read_only', True) | ||
self.make_email(self.local_user, '[email protected]') | ||
self.make_email(self.local_user, '[email protected]', verified=False) | ||
self.assert_element_count( | ||
[(self.local_user, 2)], | ||
self.url, | ||
'sodar-user-email-table-row', | ||
'class', | ||
) | ||
self.assert_element_count( | ||
[(self.local_user, 0)], | ||
self.url, | ||
'sodar-user-email-dropdown', | ||
'class', | ||
) | ||
|
||
def test_additional_email_set_read_only_superuser(self): | ||
"""Test additional email with site read-only mode as superuser""" | ||
app_settings.set('projectroles', 'site_read_only', True) | ||
self.make_email(self.superuser, '[email protected]') | ||
self.make_email(self.superuser, '[email protected]', verified=False) | ||
self.assert_element_count( | ||
[(self.superuser, 2)], | ||
self.url, | ||
'sodar-user-email-table-row', | ||
'class', | ||
) | ||
self.assert_element_count( | ||
[(self.superuser, 2)], | ||
self.url, | ||
'sodar-user-email-dropdown', | ||
'class', | ||
) | ||
|
||
@override_settings(PROJECTROLES_SEND_EMAIL=False) | ||
def test_additional_email_disabled(self): | ||
"""Test existence of email card with PROJECTROLES_SEND_EMAIL=False""" | ||
|
@@ -132,8 +208,8 @@ def test_additional_email_target(self): | |
) | ||
|
||
|
||
class TestUserSettings(UITestBase): | ||
"""Tests for user settings page""" | ||
class TestUserSettingsView(UITestBase): | ||
"""Tests for UserSettingsView""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
|