1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
12 from api.utils import common
15 class TranslateToStrTestCase(unittest.TestCase):
17 def test_translate_to_str_unicode(self):
19 output_str = common.translate_to_str(input_str)
22 self.assertEqual(result, output_str)
24 def test_translate_to_str_dict_list_unicode(self):
26 u'hello': {u'hello': [u'world']}
28 output_str = common.translate_to_str(input_str)
31 'hello': {'hello': ['world']}
33 self.assertEqual(result, output_str)
36 class GetCommandListTestCase(unittest.TestCase):
38 def test_get_command_list_no_opts(self):
42 output_list = common.get_command_list(command_list, opts, args)
44 result_list = ['a', 'b']
45 self.assertEqual(result_list, output_list)
47 def test_get_command_list_with_opts_args(self):
55 output_list = common.get_command_list(command_list, opts, args)
57 result_list = ['a', 'e', '--b', '--task-args', 'd']
58 self.assertEqual(result_list, output_list)
65 if __name__ == '__main__':