diff options
Diffstat (limited to 'ceilometerclient/tests/test_utils.py')
| -rw-r--r-- | ceilometerclient/tests/test_utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ceilometerclient/tests/test_utils.py b/ceilometerclient/tests/test_utils.py index 1f3074b..9082328 100644 --- a/ceilometerclient/tests/test_utils.py +++ b/ceilometerclient/tests/test_utils.py @@ -14,6 +14,7 @@ # under the License. +import itertools import mock import six import sys @@ -117,6 +118,33 @@ class UtilsTest(test_utils.BaseTestCase): 'other': 'value' }) + def test_args_array_to_list_of_dicts(self): + starts = ['0 11 * * *', '"0 11 * * *"', '\'0 11 * * *\''] + timezones = [None, 'US/Eastern', '"US/Eastern"', '\'US/Eastern\''] + descs = [None, 'de sc', '"de sc"', '\'de sc\''] + for start, tz, desc in itertools.product(starts, timezones, descs): + my_args = { + 'time_constraints': ['name=const1;start=%s;duration=1' + % start], + 'other': 'value' + } + expected = { + 'time_constraints': [dict(name='const1', + start='0 11 * * *', + duration='1')], + 'other': 'value' + } + if tz: + my_args['time_constraints'][0] += ';timezone=%s' % tz + expected['time_constraints'][0]['timezone'] = 'US/Eastern' + if desc: + my_args['time_constraints'][0] += ';description=%s' % desc + expected['time_constraints'][0]['description'] = 'de sc' + + cleaned = utils.args_array_to_list_of_dicts(my_args, + 'time_constraints') + self.assertEqual(expected, cleaned) + def test_key_with_slash_to_nested_dict(self): my_args = { 'combination_rule/alarm_ids': ['id1', 'id2'], |
