chg: [tests API] use argv api key

This commit is contained in:
Terrtia 2019-09-03 16:39:12 +02:00
parent 2ec96586eb
commit 9a0f7894a0
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -23,11 +23,16 @@ def parse_response(obj, ail_response):
return res_json return res_json
def get_api_key(): def get_api_key():
api_file = os.path.join(os.environ['AIL_HOME'], 'DEFAULT_PASSWORD')
if os.path.isfile(api_file):
with open(os.path.join(os.environ['AIL_HOME'], 'DEFAULT_PASSWORD'), 'r') as f: with open(os.path.join(os.environ['AIL_HOME'], 'DEFAULT_PASSWORD'), 'r') as f:
content = f.read() content = f.read()
content = content.splitlines() content = content.splitlines()
apikey = content[-1] apikey = content[-1]
apikey = apikey.replace('API_Key=', '', 1) apikey = apikey.replace('API_Key=', '', 1)
# manual tests
else:
apikey = sys.argv[1]
return apikey return apikey
APIKEY = get_api_key() APIKEY = get_api_key()
@ -162,4 +167,4 @@ class TestApiV1(unittest.TestCase):
self.assertTrue(req_json['tags']) self.assertTrue(req_json['tags'])
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main(argv=['first-arg-is-ignored'], exit=False)