-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint, Sort mocked config options
- Loading branch information
Showing
2 changed files
with
21 additions
and
19 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 |
---|---|---|
|
@@ -185,25 +185,25 @@ def __init__(self, **kwargs): | |
self.user_activation_on = False | ||
self.new_user_dataset_access_role_default_private = False | ||
|
||
self.expose_dataset_path = True | ||
self.activation_grace_period = 0 | ||
self.allow_user_dataset_purge = True | ||
self.allow_user_creation = True | ||
self.auth_config_file = "config/auth_conf.xml.sample" | ||
self.custom_activation_email_message = "custom_activation_email_message" | ||
self.email_domain_allowlist_content = None | ||
self.email_domain_blocklist_content = None | ||
self.email_from = "email_from" | ||
self.enable_old_display_applications = True | ||
self.redact_username_in_logs = False | ||
self.auth_config_file = "config/auth_conf.xml.sample" | ||
self.error_email_to = "[email protected]" | ||
self.password_expiration_period = 0 | ||
self.terms_url = "terms_url" | ||
self.expose_dataset_path = True | ||
self.hostname = "hostname" | ||
self.instance_resource_url = "instance_resource_url" | ||
self.custom_activation_email_message = "custom_activation_email_message" | ||
self.activation_grace_period = 0 | ||
self.templates_dir = "templates" | ||
self.email_from = "email_from" | ||
self.password_expiration_period = 0 | ||
self.pretty_datetime_format = "pretty_datetime_format" | ||
self.redact_username_in_logs = False | ||
self.smtp_server = True | ||
self.hostname = "hostname" | ||
self.terms_url = "terms_url" | ||
self.templates_dir = "templates" | ||
|
||
self.umask = 0o77 | ||
self.flush_per_n_datasets = 0 | ||
|
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 |
---|---|---|
|
@@ -4,11 +4,10 @@ | |
Executable directly using: python -m test.unit.managers.test_UserManager | ||
""" | ||
from datetime import datetime | ||
from unittest.mock import patch | ||
|
||
from sqlalchemy import desc | ||
|
||
from unittest import mock | ||
|
||
from galaxy import ( | ||
exceptions, | ||
model, | ||
|
@@ -192,7 +191,7 @@ def test_empty_password(self): | |
def testable_url_for(*a, **k): | ||
return f"(url_for): {k}" | ||
|
||
@mock.patch("routes.url_for", testable_url_for) | ||
@patch("routes.url_for", testable_url_for) | ||
def test_activation_email(self): | ||
self.log("should produce the activation email") | ||
self.user_manager.create(email="[email protected]", username="nopassword") | ||
|
@@ -204,16 +203,19 @@ def validate_send_email(frm, to, subject, body, config, html=None): | |
assert subject == "Galaxy Account Activation" | ||
assert "custom_activation_email_message" in body | ||
assert "Hello nopassword" in body | ||
assert "{'controller': 'user', 'action': 'activate', 'activation_token': 'activation_token', 'email': Markup('[email protected]'), 'qualified': True}" in body | ||
assert ( | ||
"{'controller': 'user', 'action': 'activate', 'activation_token': 'activation_token', 'email': Markup('[email protected]'), 'qualified': True}" | ||
in body | ||
) | ||
|
||
with mock.patch("galaxy.util.send_mail", side_effect=validate_send_email) as mock_send_mail: | ||
with mock.patch("galaxy.util.hash_util.new_secure_hash_v2", return_value="activation_token") as mock_hash_util: | ||
with patch("galaxy.util.send_mail", side_effect=validate_send_email) as mock_send_mail: | ||
with patch("galaxy.util.hash_util.new_secure_hash_v2", return_value="activation_token") as mock_hash_util: | ||
result = self.user_manager.send_activation_email(self.trans, "[email protected]", "nopassword") | ||
mock_send_mail.assert_called_once() | ||
mock_hash_util.assert_called_once() | ||
assert result is True | ||
|
||
@mock.patch("routes.url_for", testable_url_for) | ||
@patch("routes.url_for", testable_url_for) | ||
def test_reset_email(self): | ||
self.log("should produce the password reset email") | ||
self.user_manager.create(email="[email protected]", username="nopassword") | ||
|
@@ -226,8 +228,8 @@ def validate_send_email(frm, to, subject, body, config, html=None): | |
assert "reset your Galaxy password" in body | ||
assert "{'controller': 'login', 'action': 'start', 'token': 'reset_token'}" in body | ||
|
||
with mock.patch("galaxy.util.send_mail", side_effect=validate_send_email) as mock_send_mail: | ||
with mock.patch("galaxy.model.unique_id", return_value="reset_token") as mock_unique_id: | ||
with patch("galaxy.util.send_mail", side_effect=validate_send_email) as mock_send_mail: | ||
with patch("galaxy.model.unique_id", return_value="reset_token") as mock_unique_id: | ||
result = self.user_manager.send_reset_email(self.trans, dict(email="[email protected]")) | ||
mock_send_mail.assert_called_once() | ||
mock_unique_id.assert_called_once() | ||
|