Merge "unify pod keywork so api can easily used"
[yardstick.git] / tests / unit / apiserver / utils / test_common.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
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
10 import unittest
11
12 from api.utils import common
13
14
15 class TranslateToStrTestCase(unittest.TestCase):
16
17     def test_translate_to_str_unicode(self):
18         input_str = u'hello'
19         output_str = common.translate_to_str(input_str)
20
21         result = 'hello'
22         self.assertEqual(result, output_str)
23
24     def test_translate_to_str_dict_list_unicode(self):
25         input_str = {
26             u'hello': {u'hello': [u'world']}
27         }
28         output_str = common.translate_to_str(input_str)
29
30         result = {
31             'hello': {'hello': ['world']}
32         }
33         self.assertEqual(result, output_str)
34
35
36 def main():
37     unittest.main()
38
39
40 if __name__ == '__main__':
41     main()