summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-07-08 17:34:52 -0400
committerDR695H <dr695h@att.com>2019-07-08 17:35:48 -0400
commit3a8c94568d9fb3c38329a19f11f08be48fc1eadf (patch)
tree7597cba238aff636862775fb365fe9b93036976d /robotframework-onap/ONAPLibrary
parent03dadb9b9ce5c8386079bd47c54cde17f39382c4 (diff)
dd in sdnc keywords for vcpe
Change-Id: Ib3a630eeb18fdf8418b6e12c4eb781c28d8a3ffa Issue-ID: TEST-173 Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap/ONAPLibrary')
-rw-r--r--robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py90
-rw-r--r--robotframework-onap/ONAPLibrary/PreloadSDNCKeywords.py40
-rw-r--r--robotframework-onap/ONAPLibrary/SDNC.py29
3 files changed, 159 insertions, 0 deletions
diff --git a/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
new file mode 100644
index 0000000..9fa9c04
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/BaseSDNCKeywords.py
@@ -0,0 +1,90 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from RequestsLibrary import RequestsLibrary
+from robot.api import logger
+from robot.api.deco import keyword
+from robot.libraries.BuiltIn import BuiltIn
+
+from ONAPLibrary.Utilities import Utilities
+
+
+class BaseSDNCKeywords(object):
+ """SDNC is an ONAP testing library for Robot Framework that provides functionality for interacting with the network
+ controller. """
+
+ def __init__(self):
+ super(BaseSDNCKeywords, self).__init__()
+ self.application_id = "robot-ete"
+ self.uuid = Utilities()
+ self.builtin = BuiltIn()
+
+ @keyword
+ def run_get_request(self, endpoint, data_path, accept="application/json", auth=None):
+ """Runs an SDNC get request"""
+ resp = self.get_request(endpoint, data_path, accept, auth)
+ self.builtin.should_be_equal_as_strings(resp.status_code, "200")
+ return resp
+
+ @keyword
+ def run_post_request(self, endpoint, data_path, data, accept="application/json", auth=None):
+ """Runs an SDNC post request"""
+ return self.post_request(endpoint, data_path, data, accept, auth)
+
+ @keyword
+ def run_put_request(self, endpoint, data_path, data, accept="application/json", auth=None):
+ """Runs an SDNC post request"""
+ return self.put_request(endpoint, data_path, data, accept, auth)
+
+ def get_request(self, endpoint, data_path, accept="application/json", auth=None):
+ """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))
+ 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))
+ logger.info("Received response from sdnc " + resp.text)
+ return resp
+
+ def put_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().put_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ logger.info("Received response from sdnc " + resp.text)
+ return resp
+
+ def delete_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().delete_request("sdnc", data_path, data=data, headers=self.create_headers(accept))
+ logger.info("Received response from sdnc " + resp.text)
+ return resp
diff --git a/robotframework-onap/ONAPLibrary/PreloadSDNCKeywords.py b/robotframework-onap/ONAPLibrary/PreloadSDNCKeywords.py
new file mode 100644
index 0000000..baf58d4
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/PreloadSDNCKeywords.py
@@ -0,0 +1,40 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from ONAPLibrary.BaseSDNCKeywords import BaseSDNCKeywords
+from ONAPLibrary.UUIDKeywords import UUIDKeywords
+from ONAPLibrary.TemplatingKeywords import TemplatingKeywords
+from robot.api.deco import keyword
+from robot.libraries.BuiltIn import BuiltIn
+from robot.libraries.OperatingSystem import OperatingSystem
+
+
+class PreloadSDNCKeywords(object):
+ """SDNC is an ONAP testing library for Robot Framework that provides functionality for interacting with the network
+ controller. """
+
+ def __init__(self):
+ super(PreloadSDNCKeywords, self).__init__()
+ self.application_id = "robot-ete"
+ self.builtin = BuiltIn()
+ self.base_keywords = BaseSDNCKeywords()
+ self.utilities = UUIDKeywords()
+ self.os = OperatingSystem()
+ self.templating = TemplatingKeywords()
+
+ @keyword
+ def preload_vfmodule(self, endpoint, data_path, templates_folder, template, preload_dictionary):
+ """Runs an SDNC request to preload certain data."""
+ self.templating.create_environment("sdnc", templates_folder)
+ data = self.templating.apply_template("sdnc", template, preload_dictionary)
+ return self.base_keywords.post_request(endpoint, data_path, data)
diff --git a/robotframework-onap/ONAPLibrary/SDNC.py b/robotframework-onap/ONAPLibrary/SDNC.py
new file mode 100644
index 0000000..bd16ae4
--- /dev/null
+++ b/robotframework-onap/ONAPLibrary/SDNC.py
@@ -0,0 +1,29 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from ONAPLibrary.PreloadSDNCKeywords import PreloadSDNCKeywords
+from ONAPLibrary.robotlibcore import HybridCore
+from ONAPLibrary.BaseSDNCKeywords import BaseSDNCKeywords
+
+
+class SDNC(HybridCore):
+ """SDNC is an ONAP testing library for Robot Framework that provides functionality for interacting with the network
+ controller. """
+
+ def __init__(self):
+ self.keyword_implementors = [
+ BaseSDNCKeywords(),
+ PreloadSDNCKeywords()
+ ]
+ HybridCore.__init__(self, self.keyword_implementors)