summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-07-11 11:02:06 -0400
committerDR695H <dr695h@att.com>2019-07-11 11:02:06 -0400
commit1afa01d5848f9a7a99c436397ebc019cee7fb362 (patch)
tree95c961c4b4b46c87c36c8ed0c6c229ac99727222 /robotframework-onap/ONAPLibrary/BaseSOKeywords.py
parent4648e856a8faf2517f2b2335ca6a4ba8d8a20fe5 (diff)
refacotr out headers so they are common across ecomp
Issue-ID: TEST-173 Change-Id: I55e5e4e6cc5e2a684858e94a485debc2b21d283d Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap/ONAPLibrary/BaseSOKeywords.py')
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSOKeywords.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/robotframework-onap/ONAPLibrary/BaseSOKeywords.py b/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
index 80ae40c..f262616 100644
--- a/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
+++ b/robotframework-onap/ONAPLibrary/BaseSOKeywords.py
@@ -16,7 +16,7 @@ from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
-from ONAPLibrary.Utilities import Utilities
+from ONAPLibrary.RequestsHelper import RequestsHelper
class BaseSOKeywords(object):
@@ -25,8 +25,7 @@ class BaseSOKeywords(object):
def __init__(self):
super(BaseSOKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -50,26 +49,17 @@ class BaseSOKeywords(object):
"""Runs an SO get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("so", data_path, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().get_request("so", data_path, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by so"""
- uuid = self.uuid.generate_uuid4()
- headers = {
- "Accept": accept,
- "Content-Type": "application/json",
- "X-TransactionId": self.application_id + "-" + uuid,
- "X-FromAppId": self.application_id
- }
- return headers
-
def post_request(self, endpoint, data_path, data, accept="application/json", auth=None):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().post_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().post_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
@@ -77,7 +67,8 @@ class BaseSOKeywords(object):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().put_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().put_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp
@@ -85,6 +76,7 @@ class BaseSOKeywords(object):
"""Runs an SO post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("so", endpoint, auth=auth)
- resp = RequestsLibrary().delete_request("so", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().delete_request("so", data_path, data=data, headers=headers)
logger.info("Received response from so " + resp.text)
return resp