Skip to content

Commit c4208c0

Browse files
committed
feat: set api_domain on base domain env
1 parent 8c1a425 commit c4208c0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

nasdaqdatalink/api_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ def read_key_from_environment_variable():
103103

104104

105105
def read_api_base_from_environment_variable():
106-
api_base = os.environ.get(NASDAQ_DATA_LINK_BASE_DOMAIN)
107-
if not api_base:
106+
base_domain = os.environ.get(NASDAQ_DATA_LINK_BASE_DOMAIN)
107+
if not base_domain:
108108
raise_empty_environment_variable(NASDAQ_DATA_LINK_BASE_DOMAIN)
109109

110-
ApiConfig.api_base = api_base
110+
ApiConfig.api_base = '{}{}/api/v3'.format(ApiConfig.api_protocol, base_domain)
111111

112112

113113
def read_key(filename=None):

test/test_api_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ def test_read_key_from_file_with_multi_newline(self):
138138
given = "keyfordefaultfile\n\nanotherkey\n"
139139
self._read_key_from_file_helper(given, TEST_DEFAULT_FILE_CONTENTS)
140140

141+
141142
def test_read_config_when_environment_variable_set(self):
142-
os.environ['NASDAQ_DATA_LINK_BASE_DOMAIN'] = 'api-basein-env'
143+
os.environ['NASDAQ_DATA_LINK_BASE_DOMAIN'] = 'testdatalinkdomain.com'
143144
ApiConfig.api_base = None
144145
read_config()
145-
self.assertEqual(ApiConfig.api_base, 'api-basein-env')
146+
self.assertEqual(ApiConfig.api_base, '{}testdatalinkdomain.com/api/v3'.format(ApiConfig.api_protocol))
146147

147148

148149
def test_read_config_when_environment_variable_not_set(self):
@@ -153,5 +154,7 @@ def test_read_config_when_environment_variable_not_set(self):
153154

154155
def test_read_config_when_env_key_empty(self):
155156
os.environ['NASDAQ_DATA_LINK_BASE_DOMAIN'] = ''
157+
ApiConfig.api_base = 'prevapibase'
156158
with self.assertRaises(ValueError):
157159
read_config()
160+
self.assertEqual(ApiConfig.api_base, 'prevapibase')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy