1 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from robot.api.deco import keyword
16 from robot.libraries.BuiltIn import BuiltIn
18 from ONAPLibrary.RequestsHelper import RequestsHelper
21 class MUSICKeywords(object):
22 """MUSIC is an ONAP testing library for Robot Framework that provides functionality for interacting with the serivce
26 super(MUSICKeywords, self).__init__()
27 self.reqs = RequestsHelper()
28 self.builtin = BuiltIn()
31 def run_get_request(self, endpoint, data_path, accept="application/json", auth=None):
32 """Runs an MUSIC get request"""
33 resp = self.reqs.get_request("music", endpoint, data_path, accept, auth)
36 def run_health_check(self, endpoint, health_check_path):
37 """Runs MUSIC Health check"""
38 resp = self.run_get_request(endpoint, health_check_path)
39 self.builtin.should_be_equal_as_strings(resp.status_code, "200")
40 self.builtin.should_be_equal_as_strings(resp.json()['status'], "SUCCESS")
42 def run_cassandra_connection_check(self, endpoint, health_check_path):
43 """Confirm MUSIC's connection to Cassandra in active"""
44 resp = self.run_get_request(endpoint, health_check_path)
45 self.builtin.should_be_equal_as_strings(resp.status_code, "200")
46 self.builtin.should_be_equal_as_strings(resp.json()['Cassandra'], "Active")