Update INFO.yaml with new PTL
[testsuite/python-testing-utils.git] / robotframework-onap / ONAPLibrary / VESProtobuf.py
index d747a0d..2bf7f6d 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# noinspection PyPackageRequirements
 from google.protobuf import descriptor
-# noinspection PyPackageRequirements
 from google.protobuf import descriptor_pb2
-# noinspection PyPackageRequirements
 from google.protobuf import message_factory
-# noinspection PyPackageRequirements
 from google.protobuf.json_format import MessageToJson
 
 
@@ -27,6 +23,7 @@ class VESProtobuf(object):
 
     def __init__(self):
         super(VESProtobuf, self).__init__()
+        self.message_descriptors = VESProtobuf.get_message_definitions()
 
     @staticmethod
     def create_ves_event():
@@ -109,12 +106,12 @@ class VESProtobuf(object):
 
     @staticmethod
     def get_message_definitions():
-        return message_factory.GetMessages((VESProtobuf.create_ves_event(),))
+        messages = message_factory.GetMessages((VESProtobuf.create_ves_event(),))
+        message_factory._FACTORY = message_factory.MessageFactory()
+        return messages
 
-    @staticmethod
-    def binary_to_json(binary_message):
-        defs = VESProtobuf.get_message_definitions()
-        ves = defs['VesEvent']()
+    def binary_to_json(self, binary_message):
+        ves = self.message_descriptors['VesEvent']()
         ves.MergeFromString(binary_message)
         json = MessageToJson(ves)
         return json