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 ONAPLibrary.VESProtobuf import VESProtobuf
16 from ONAPLibrary.JSONKeywords import JSONKeywords
17 from robot.api.deco import keyword
20 class ProtobufKeywords(object):
21 """ Utilities useful for Protobuf manipulation """
24 super(ProtobufKeywords, self).__init__()
25 self.vpf = VESProtobuf()
28 def compare_file_to_message(self, file_name, message):
29 with open(file_name, "rb") as file_to_do:
30 return self.compare_two_messages(file_to_do.read(), message)
32 def compare_two_messages(self, left, right):
33 left_json = self.vpf.binary_to_json(left)
34 right_json = self.vpf.binary_to_json(right)
35 return JSONKeywords().json_equals(left_json, right_json)