3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.benchmark.scenarios.parser.Parser
18 from yardstick.benchmark.scenarios.parser import parser
20 @mock.patch('yardstick.benchmark.scenarios.parser.parser.subprocess')
21 class ParserTestCase(unittest.TestCase):
26 def test_parser_successful_setup(self, mock_subprocess):
28 p = parser.Parser({}, {})
29 mock_subprocess.call().return_value = 0
31 self.assertEqual(p.setup_done, True)
33 def test_parser_successful(self, mock_subprocess):
35 'options': {'yangfile':'/root/yardstick/samples/yang.yaml',
36 'toscafile':'/root/yardstick/samples/tosca.yaml'},
38 p = parser.Parser(args, {})
40 mock_subprocess.call().return_value = 0
41 sample_output = '{"yangtotosca": "success"}'
44 expected_result = json.loads(sample_output)
46 def test_parser_teardown_successful(self, mock_subprocess):
48 p = parser.Parser({}, {})
49 mock_subprocess.call().return_value = 0
51 self.assertEqual(p.teardown_done, True)
57 if __name__ == '__main__':