summaryrefslogtreecommitdiffstats
path: root/utils/test/scripts/shared_utils.py
diff options
context:
space:
mode:
authorJuraj Linkes <jlinkes@cisco.com>2016-06-21 09:34:21 +0200
committerJose Lausuch <jose.lausuch@ericsson.com>2016-06-23 07:57:35 +0000
commit03cef9a0a43b43f0757b749d7b42e05d9cb37609 (patch)
treec9b010bdf58d577d4c436745999db9f1e8b3f973 /utils/test/scripts/shared_utils.py
parentdb0085ebc1b1741034b73533d9babeab13e40e14 (diff)
introduced fixes for changes in database for Colorado
Change-Id: Ib6196d7da8701f9c799cabfaa0c57c97e2edb631 Signed-off-by: Juraj Linkes <jlinkes@cisco.com>
Diffstat (limited to 'utils/test/scripts/shared_utils.py')
-rw-r--r--utils/test/scripts/shared_utils.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/utils/test/scripts/shared_utils.py b/utils/test/scripts/shared_utils.py
index 899f844ec..91ce38e45 100644
--- a/utils/test/scripts/shared_utils.py
+++ b/utils/test/scripts/shared_utils.py
@@ -3,17 +3,17 @@ import json
http = urllib3.PoolManager()
-def delete_request(url, username, password, body=None):
- headers = urllib3.util.make_headers(basic_auth=':'.join([username, password]))
+def delete_request(url, creds, body=None):
+ headers = urllib3.make_headers(basic_auth=creds)
http.request('DELETE', url, headers=headers, body=body)
-def publish_json(json_ojb, username, password, output_destination):
+def publish_json(json_ojb, creds, output_destination):
json_dump = json.dumps(json_ojb)
if output_destination == 'stdout':
print json_dump
else:
- headers = urllib3.util.make_headers(basic_auth=':'.join([username, password]))
+ headers = urllib3.make_headers(basic_auth=creds)
http.request('POST', output_destination, headers=headers, body=json_dump)
@@ -21,9 +21,9 @@ def _get_nr_of_hits(elastic_json):
return elastic_json['hits']['total']
-def get_elastic_data(elastic_url, username, password, body, field='_source'):
+def get_elastic_data(elastic_url, creds, body, field='_source'):
# 1. get the number of results
- headers = urllib3.util.make_headers(basic_auth=':'.join([username, password]))
+ headers = urllib3.make_headers(basic_auth=creds)
elastic_json = json.loads(http.request('GET', elastic_url + '/_search?size=0', headers=headers, body=body).data)
nr_of_hits = _get_nr_of_hits(elastic_json)
@@ -34,3 +34,4 @@ def get_elastic_data(elastic_url, username, password, body, field='_source'):
for hit in elastic_json['hits']['hits']:
elastic_data.append(hit[field])
return elastic_data
+