diff options
author | DR695H <dr695h@att.com> | 2019-07-11 11:02:06 -0400 |
---|---|---|
committer | DR695H <dr695h@att.com> | 2019-07-11 11:02:06 -0400 |
commit | 1afa01d5848f9a7a99c436397ebc019cee7fb362 (patch) | |
tree | 95c961c4b4b46c87c36c8ed0c6c229ac99727222 /robotframework-onap/ONAPLibrary/SNIROKeywords.py | |
parent | 4648e856a8faf2517f2b2335ca6a4ba8d8a20fe5 (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/SNIROKeywords.py')
-rw-r--r-- | robotframework-onap/ONAPLibrary/SNIROKeywords.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/robotframework-onap/ONAPLibrary/SNIROKeywords.py b/robotframework-onap/ONAPLibrary/SNIROKeywords.py index 8e97529..f9750da 100644 --- a/robotframework-onap/ONAPLibrary/SNIROKeywords.py +++ b/robotframework-onap/ONAPLibrary/SNIROKeywords.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 from ONAPLibrary.TemplatingKeywords import TemplatingKeywords from ONAPLibrary.Base64Keywords import Base64Keywords @@ -27,8 +27,7 @@ class SNIROKeywords(object): def __init__(self): super(SNIROKeywords, self).__init__() - self.application_id = "robot-ete" - self.uuid = Utilities() + self.reqs = RequestsHelper() self.templating = TemplatingKeywords() self.base64 = Base64Keywords() self.builtin = BuiltIn() @@ -69,7 +68,8 @@ class SNIROKeywords(object): """Runs an SNIRO 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,17 +77,6 @@ class SNIROKeywords(object): """Runs an SNIRO get request""" logger.info("Creating session" + endpoint) RequestsLibrary().create_session("sniro", endpoint, auth=auth) - resp = RequestsLibrary().get_request("sniro", data_path, headers=self.create_headers(accept)) + resp = RequestsLibrary().get_request("sniro", data_path, headers=self.reqs.create_headers(accept=accept)) logger.info("Received response from OOF-SNIRO " + 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 |