moving http to new keyword format
[testsuite/python-testing-utils.git] / robotframework-onap / ONAPLibrary / ProtobufKeywords.py
1 from ONAPLibrary.VESProtobuf import *
2 from ONAPLibrary.JSONKeywords import JSONKeywords
3 from robot.api.deco import keyword
4
5
6 class ProtobufKeywords(object):
7     """ Utilities useful for Protobuf manipulation """
8
9     def __init__(self):
10         super(ProtobufKeywords, self).__init__()
11
12     @keyword
13     def compare_file_to_message(self, file_name, message):
14         with open(file_name, "rb") as file_to_do:
15             return self.compare_two_messages(file_to_do.read(), message)
16
17     @staticmethod
18     def compare_two_messages(left, right):
19         left_json = VESProtobuf.binary_to_json(left)
20         right_json = VESProtobuf.binary_to_json(right)
21         return JSONKeywords().json_equals(left_json, right_json)