summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
diff options
context:
space:
mode:
Diffstat (limited to 'robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py')
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py27
1 files changed, 9 insertions, 18 deletions
diff --git a/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
index 9fa9c04..14bfb54 100644
--- a/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
+++ b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.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 BaseSDNCKeywords(object):
@@ -25,8 +25,7 @@ class BaseSDNCKeywords(object):
def __init__(self):
super(BaseSDNCKeywords, self).__init__()
- self.application_id = "robot-ete"
- self.uuid = Utilities()
+ self.reqs = RequestsHelper()
self.builtin = BuiltIn()
@keyword
@@ -50,26 +49,16 @@ class BaseSDNCKeywords(object):
"""Runs an SDNC get request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().get_request("sdnc", data_path, headers=self.create_headers(accept))
+ resp = RequestsLibrary().get_request("sdnc", data_path, headers=self.reqs.create_headers(accept))
logger.info("Received response from sdnc " + resp.text)
return resp
- def create_headers(self, accept="application/json"):
- """Create the headers that are used by sdnc"""
- 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 sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().post_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().post_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp
@@ -77,7 +66,8 @@ class BaseSDNCKeywords(object):
"""Runs an sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().put_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().put_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp
@@ -85,6 +75,7 @@ class BaseSDNCKeywords(object):
"""Runs an sdnc post request"""
logger.info("Creating session" + endpoint)
RequestsLibrary().create_session("sdnc", endpoint, auth=auth)
- resp = RequestsLibrary().delete_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ headers = self.reqs.create_headers(accept=accept)
+ resp = RequestsLibrary().delete_request("sdnc", data_path, data=data, headers=headers)
logger.info("Received response from sdnc " + resp.text)
return resp