DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 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. |
DR695H | 27daa1a | 2019-07-22 18:20:48 -0400 | [diff] [blame] | 14 | |
DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 15 | from robot.api.deco import keyword |
| 16 | from robot.libraries.BuiltIn import BuiltIn |
| 17 | |
DR695H | 1afa01d | 2019-07-11 11:02:06 -0400 | [diff] [blame] | 18 | from ONAPLibrary.RequestsHelper import RequestsHelper |
DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 19 | |
| 20 | |
| 21 | class BaseSDNCKeywords(object): |
| 22 | """SDNC is an ONAP testing library for Robot Framework that provides functionality for interacting with the network |
| 23 | controller. """ |
| 24 | |
| 25 | def __init__(self): |
| 26 | super(BaseSDNCKeywords, self).__init__() |
DR695H | 1afa01d | 2019-07-11 11:02:06 -0400 | [diff] [blame] | 27 | self.reqs = RequestsHelper() |
DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 28 | self.builtin = BuiltIn() |
| 29 | |
| 30 | @keyword |
| 31 | def run_get_request(self, endpoint, data_path, accept="application/json", auth=None): |
| 32 | """Runs an SDNC get request""" |
DR695H | afd5237 | 2019-08-12 18:17:19 -0400 | [diff] [blame] | 33 | resp = self.reqs.get_request(alias="sdnc", endpoint=endpoint, data_path=data_path, accept=accept, auth=auth) |
DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 34 | self.builtin.should_be_equal_as_strings(resp.status_code, "200") |
| 35 | return resp |
| 36 | |
| 37 | @keyword |
| 38 | def run_post_request(self, endpoint, data_path, data, accept="application/json", auth=None): |
| 39 | """Runs an SDNC post request""" |
DR695H | afd5237 | 2019-08-12 18:17:19 -0400 | [diff] [blame] | 40 | return self.reqs.post_request(alias="sdnc", endpoint=endpoint, data_path=data_path, data=data, accept=accept, |
| 41 | auth=auth) |
DR695H | 3a8c945 | 2019-07-08 17:34:52 -0400 | [diff] [blame] | 42 | |
| 43 | @keyword |
| 44 | def run_put_request(self, endpoint, data_path, data, accept="application/json", auth=None): |
| 45 | """Runs an SDNC post request""" |
DR695H | afd5237 | 2019-08-12 18:17:19 -0400 | [diff] [blame] | 46 | return self.reqs.put_request(alias="sdnc", endpoint=endpoint, data_path=data_path, data=data, accept=accept, |
| 47 | auth=auth) |