Merge "Add deployment scripts for vRNC"
[parser.git] / tosca2heat / heat-translator / translator / hot / tests / test_hot_parameter.py
1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
2 #    not use this file except in compliance with the License. You may obtain
3 #    a copy of the License at
4 #
5 #         http://www.apache.org/licenses/LICENSE-2.0
6 #
7 #    Unless required by applicable law or agreed to in writing, software
8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 #    License for the specific language governing permissions and limitations
11 #    under the License.
12
13 from collections import OrderedDict
14
15 from toscaparser.tests.base import TestCase
16 from translator.hot.syntax.hot_parameter import CONSTRAINTS
17 from translator.hot.syntax.hot_parameter import DEFAULT
18 from translator.hot.syntax.hot_parameter import DESCRIPTION
19 from translator.hot.syntax.hot_parameter import HIDDEN
20 from translator.hot.syntax.hot_parameter import HotParameter
21 from translator.hot.syntax.hot_parameter import LABEL
22 from translator.hot.syntax.hot_parameter import TYPE
23
24 TEST_CONSTRAINTS = {'equal': 'allowed_values', 'greater_than': 'range'}
25
26
27 class HotParameterTest(TestCase):
28
29     # This test ensures the variables set during the creation of a HotParameter
30     # object are returned in an OrderedDict when calling get_dict_output().
31     def test_dict_output(self):
32         name = 'HotParameterTest'
33         hot_parameter = HotParameter(name, 'Type',
34                                      label='Label',
35                                      description='Description',
36                                      default='Default',
37                                      hidden=True,
38                                      constraints=TEST_CONSTRAINTS)
39         expected_dict = OrderedDict([(TYPE, 'Type'), (LABEL, 'Label'),
40                                      (DESCRIPTION, 'Description'),
41                                      (DEFAULT, 'Default'), (HIDDEN, True),
42                                      (CONSTRAINTS, TEST_CONSTRAINTS)])
43
44         self.assertEqual(hot_parameter.get_dict_output()[name], expected_dict)