moving basic rest calls to requestshelper
[testsuite/python-testing-utils.git] / robotframework-onap / ONAPLibrary / BaseSDNCKeywords.py
1 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from RequestsLibrary import RequestsLibrary
15 from robot.api import logger
16 from robot.api.deco import keyword
17 from robot.libraries.BuiltIn import BuiltIn
18
19 from ONAPLibrary.RequestsHelper import RequestsHelper
20
21
22 class BaseSDNCKeywords(object):
23     """SDNC is an ONAP testing library for Robot Framework that provides functionality for interacting with the network
24     controller. """
25
26     def __init__(self):
27         super(BaseSDNCKeywords, self).__init__()
28         self.reqs = RequestsHelper()
29         self.builtin = BuiltIn()
30
31     @keyword
32     def run_get_request(self, endpoint, data_path, accept="application/json", auth=None):
33         """Runs an SDNC get request"""
34         resp = self.reqs.get_request("sdnc", endpoint, data_path, accept, auth)
35         self.builtin.should_be_equal_as_strings(resp.status_code, "200")
36         return resp
37
38     @keyword
39     def run_post_request(self, endpoint, data_path, data, accept="application/json", auth=None):
40         """Runs an SDNC post request"""
41         return self.reqs.post_request("sdnc", endpoint, data_path, data, accept, auth)
42
43     @keyword
44     def run_put_request(self, endpoint, data_path, data, accept="application/json", auth=None):
45         """Runs an SDNC post request"""
46         return self.reqs.put_request("sdnc", endpoint, data_path, data, accept, auth)