@@ -286,29 +286,34 @@ def setUp(self):
286286class SgTestConfig (object ):
287287 '''Reads test config and holds values'''
288288 def __init__ (self ):
289- self .mock = True
290- self .server_url = None
291- self .script_name = None
292- self .api_key = None
293- self .http_proxy = None
294- self .session_uuid = None
295- self .project_name = None
296- self .human_name = None
297- self .human_login = None
298- self .human_password = None
299- self .asset_code = None
300- self .version_code = None
301- self .shot_code = None
302- self .task_content = None
289+
290+ for key in self .config_keys ():
291+ value = None
292+ if key in ['mock' ]:
293+ value = True
294+ # Look for any environment variables that match our test
295+ # configuration naming of "SG_{KEY}". Default is None.
296+ value = os .environ .get ('SG_{0}' .format (str (key ).upper ()))
297+ setattr (self , key , value )
298+
299+ def config_keys (self ):
300+ return [
301+ 'api_key' , 'asset_code' , 'http_proxy' , 'human_login' , 'human_name' ,
302+ 'human_password' , 'mock' , 'project_name' , 'script_name' ,
303+ 'server_url' , 'session_uuid' , 'shot_code' , 'task_content' ,
304+ 'version_code'
305+ ]
303306
304307 def read_config (self , config_path ):
305308 config_parser = ConfigParser ()
306309 config_parser .read (config_path )
307310 for section in config_parser .sections ():
308311 for option in config_parser .options (section ):
309- value = (os .environ .get ('SG_{0}' .format (str (option ).upper ())) or
310- config_parser .get (section , option ))
311- setattr (self , option , value )
312+ # We only care about the configuration file if an environment
313+ # variable has not already been set
314+ if not getattr (self , option , None ):
315+ value = config_parser .get (section , option )
316+ setattr (self , option , value )
312317
313318
314319def _find_or_create_entity (sg , entity_type , data , identifyiers = None ):
0 commit comments