('basic',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-one-param',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-static-param',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-static-param-sample',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-private',
{'template': basic_private_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('mandatory',
{'template': mandatory_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-sample',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-resource-registry',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('basic-hidden',
{'template': basic_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('missing-param',
{'template': basic_template,
'exception': RuntimeError,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
('percent-index',
{'template': index_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
# Type: string
FooParam: '%index%'
+''',
+ }),
+ ('nested',
+ {'template': multiline_template,
+ 'exception': None,
+ 'input_file': '''environments:
+ -
+ name: basic
+ title: Basic Environment
+ description: Basic description
+ files:
+ foo.yaml:
+ parameters: all
+ children:
+ - name: nested
+ title: Nested Environment
+ description: Nested description
+ sample_values:
+ FooParam: bar
+''',
+ 'expected_output': '''# title: Basic Environment
+# description: |
+# Basic description
+parameter_defaults:
+ # Parameter with
+ # multi-line description
+ # Type: string
+ FooParam: ''
+
+''',
+ 'nested_output': '''# title: Nested Environment
+# description: |
+# Nested description
+parameter_defaults:
+ # Parameter with
+ # multi-line description
+ # Type: string
+ FooParam: bar
+
''',
}),
('multi-line-desc',
{'template': multiline_template,
'exception': None,
+ 'nested_output': '',
'input_file': '''environments:
-
name: basic
fake_output = open(fake_output_path, 'w')
with mock.patch('tripleo_heat_templates.environment_generator.open',
create=True) as mock_open:
- mock_open.side_effect = [fake_input, fake_template, fake_output]
+ mock_se = [fake_input, fake_template, fake_output]
+ if self.nested_output:
+ _, fake_nested_output_path = tempfile.mkstemp()
+ fake_nested_output = open(fake_nested_output_path, 'w')
+ fake_template2 = io.StringIO(six.text_type(self.template))
+ mock_se = [fake_input, fake_template, fake_output,
+ fake_template2, fake_nested_output]
+ mock_open.side_effect = mock_se
if not self.exception:
environment_generator.generate_environments('ignored.yaml')
else:
expected = environment_generator._FILE_HEADER + self.expected_output
with open(fake_output_path) as f:
self.assertEqual(expected, f.read())
+ if self.nested_output:
+ with open(fake_nested_output_path) as f:
+ expected = (environment_generator._FILE_HEADER +
+ self.nested_output)
+ self.assertEqual(expected, f.read())
GeneratorTestCase.generate_scenarios()