cleanup how message factory is used
[testsuite/python-testing-utils.git] / robotframework-onap / tests / ONAPLibrary / ProtobufKeywordsTest.py
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.
14 import os
15
16 from unittest import TestCase
17
18 from ONAPLibrary.ProtobufKeywords import ProtobufKeywords
19
20
21 class ProtobufKeywordsTest(TestCase):
22
23     @staticmethod
24     def _get_location():
25         path = os.path.realpath(
26             os.path.join(os.getcwd(), os.path.dirname(__file__)))
27         return path
28
29     def test(self):
30         with open(os.path.join(self._get_location(), "hvves_msg.raw"), "rb") as fileToDo:
31             value = fileToDo.read()
32         pb = ProtobufKeywords()
33         result = pb.compare_file_to_message(os.path.join(self._get_location(), "hvves_msg.raw"), value)
34         self.assertTrue(result)
35
36     def test_compare_two(self):
37         with open(os.path.join(self._get_location(), "hvves_msg.raw"), "rb") as fileToDo:
38             value = fileToDo.read()
39         pb = ProtobufKeywords()
40         result = pb.compare_two_messages(value, value)
41         self.assertTrue(result)
42
43     def test_compare_two_many(self):
44         with open(os.path.join(self._get_location(), "hvves_msg.raw"), "rb") as fileToDo:
45             value = fileToDo.read()
46         pb = ProtobufKeywords()
47         result = pb.compare_two_messages(value, value)
48         self.assertTrue(result)
49         result = pb.compare_two_messages(value, value)
50         self.assertTrue(result)