-
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 config field server_timezone (#84)
- Loading branch information
1 parent
2afcd0c
commit 8f5635b
Showing
4 changed files
with
107 additions
and
68 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ TEST: | |
Proteomics/DOG_552: 6 | ||
Proteomics/DUCK_666: 12 | ||
job_notification_emails: [email protected] [email protected] | ||
server_timezone: UTC | ||
|
||
STANDBY: | ||
base_url: https://standby-server.uzh.ch/mystandby |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import unittest | ||
from pathlib import Path | ||
|
||
from bfabric.bfabric_config import BfabricConfig, BfabricAuth, read_config | ||
from bfabric.bfabric_config import BfabricAuth, BfabricConfig, read_config | ||
|
||
|
||
class TestBfabricAuth(unittest.TestCase): | ||
|
@@ -22,6 +22,7 @@ def setUp(self): | |
self.config = BfabricConfig( | ||
base_url="url", | ||
application_ids={"app": 1}, | ||
server_timezone="t/z", | ||
) | ||
self.example_config_path = Path(__file__).parent / "example_config.yml" | ||
|
||
|
@@ -58,7 +59,7 @@ def test_copy_with_replaced_when_none(self): | |
# TODO: Test that logging is consistent with initialization | ||
def test_read_yml_bypath_default(self): | ||
# Ensure environment variable is not available, and the default is environment is loaded | ||
os.environ.pop('BFABRICPY_CONFIG_ENV', None) | ||
os.environ.pop("BFABRICPY_CONFIG_ENV", None) | ||
|
||
config, auth = read_config(self.example_config_path) | ||
self.assertEqual("my_epic_production_login", auth.login) | ||
|
@@ -80,7 +81,7 @@ def test_read_yml_bypath_environment_variable(self): | |
# TODO: Test that logging is consistent with default config | ||
def test_read_yml_bypath_all_fields(self): | ||
with self.assertLogs(level="INFO") as log_context: | ||
config, auth = read_config(self.example_config_path, config_env='TEST') | ||
config, auth = read_config(self.example_config_path, config_env="TEST") | ||
|
||
# # Testing log | ||
# self.assertEqual( | ||
|
@@ -96,42 +97,47 @@ def test_read_yml_bypath_all_fields(self): | |
self.assertEqual("https://mega-test-server.uzh.ch/mytest", config.base_url) | ||
|
||
applications_dict_ground_truth = { | ||
'Proteomics/CAT_123': 7, | ||
'Proteomics/DOG_552': 6, | ||
'Proteomics/DUCK_666': 12 | ||
"Proteomics/CAT_123": 7, | ||
"Proteomics/DOG_552": 6, | ||
"Proteomics/DUCK_666": 12, | ||
} | ||
|
||
job_notification_emails_ground_truth = "[email protected] [email protected]" | ||
|
||
self.assertEqual(applications_dict_ground_truth, config.application_ids) | ||
self.assertEqual(job_notification_emails_ground_truth, config.job_notification_emails) | ||
self.assertEqual("UTC", config.server_timezone) | ||
|
||
# Testing that we can load base_url without authentication if correctly requested | ||
def test_read_yml_when_empty_optional(self): | ||
with self.assertLogs(level="INFO"): | ||
config, auth = read_config(self.example_config_path, config_env='STANDBY', optional_auth=True) | ||
config, auth = read_config(self.example_config_path, config_env="STANDBY") | ||
|
||
self.assertIsNone(auth) | ||
self.assertEqual("https://standby-server.uzh.ch/mystandby", config.base_url) | ||
self.assertEqual({}, config.application_ids) | ||
self.assertEqual("", config.job_notification_emails) | ||
self.assertEqual("Europe/Zurich", config.server_timezone) | ||
|
||
# TODO delete if no mandatory fields are reintroduced | ||
# Test that missing authentication will raise an error if required | ||
def test_read_yml_when_empty_mandatory(self): | ||
with self.assertRaises(ValueError): | ||
read_config(self.example_config_path, config_env='STANDBY', optional_auth=False) | ||
#def test_read_yml_when_empty_mandatory(self): | ||
# with self.assertRaises(BfabricConfigError): | ||
# read_config(self.example_config_path, config_env="STANDBY") | ||
|
||
def test_repr(self): | ||
rep = repr(self.config) | ||
self.assertEqual( | ||
"BfabricConfig(base_url='url', application_ids={'app': 1}, job_notification_emails='')", | ||
"BfabricConfig(base_url='url', application_ids={'app': 1}, " | ||
"job_notification_emails='', server_timezone='t/z')", | ||
rep, | ||
) | ||
|
||
def test_str(self): | ||
rep = str(self.config) | ||
self.assertEqual( | ||
"BfabricConfig(base_url='url', application_ids={'app': 1}, job_notification_emails='')", | ||
"BfabricConfig(base_url='url', application_ids={'app': 1}, " | ||
"job_notification_emails='', server_timezone='t/z')", | ||
rep, | ||
) | ||
|
||
|