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
14 from __future__ import absolute_import
19 from oslo_serialization import jsonutils
21 from yardstick.benchmark.scenarios.parser import parser
24 @mock.patch('yardstick.benchmark.scenarios.parser.parser.subprocess')
25 class ParserTestCase(unittest.TestCase):
30 def test_parser_successful_setup(self, mock_subprocess):
32 p = parser.Parser({}, {})
33 mock_subprocess.call().return_value = 0
35 self.assertEqual(p.setup_done, True)
37 def test_parser_successful(self, mock_subprocess):
39 'options': {'yangfile': '/root/yardstick/samples/yang.yaml',
40 'toscafile': '/root/yardstick/samples/tosca.yaml'},
42 p = parser.Parser(args, {})
44 mock_subprocess.call().return_value = 0
45 sample_output = '{"yangtotosca": "success"}'
48 expected_result = jsonutils.loads(sample_output)
50 def test_parser_teardown_successful(self, mock_subprocess):
52 p = parser.Parser({}, {})
53 mock_subprocess.call().return_value = 0
55 self.assertEqual(p.teardown_done, True)
61 if __name__ == '__main__':