File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -103,11 +103,11 @@ def read_key_from_environment_variable():
103
103
104
104
105
105
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 :
108
108
raise_empty_environment_variable (NASDAQ_DATA_LINK_BASE_DOMAIN )
109
109
110
- ApiConfig .api_base = api_base
110
+ ApiConfig .api_base = '{}{}/api/v3' . format ( ApiConfig . api_protocol , base_domain )
111
111
112
112
113
113
def read_key (filename = None ):
Original file line number Diff line number Diff line change @@ -138,11 +138,12 @@ def test_read_key_from_file_with_multi_newline(self):
138
138
given = "keyfordefaultfile\n \n anotherkey\n "
139
139
self ._read_key_from_file_helper (given , TEST_DEFAULT_FILE_CONTENTS )
140
140
141
+
141
142
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 '
143
144
ApiConfig .api_base = None
144
145
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 ) )
146
147
147
148
148
149
def test_read_config_when_environment_variable_not_set (self ):
@@ -153,5 +154,7 @@ def test_read_config_when_environment_variable_not_set(self):
153
154
154
155
def test_read_config_when_env_key_empty (self ):
155
156
os .environ ['NASDAQ_DATA_LINK_BASE_DOMAIN' ] = ''
157
+ ApiConfig .api_base = 'prevapibase'
156
158
with self .assertRaises (ValueError ):
157
159
read_config ()
160
+ self .assertEqual (ApiConfig .api_base , 'prevapibase' )
You can’t perform that action at this time.
0 commit comments