Added ordered hashes.

This commit is contained in:
Jeff Baskin 2017-01-18 21:38:51 -05:00
parent 243ab902ab
commit da070c862b
2 changed files with 11 additions and 2 deletions

View File

@ -17,10 +17,14 @@
{{- '}\n' -}}
{%- endif -%}
{%- else -%}
{%- if recurse > 0 -%}
{{- '{\n' -}}
{%- endif -%}
{%- for item in data -%}
{{- keepalived_config(item) -}}
{%- endfor -%}
{%- if recurse > 0 -%}
{{- '}\n' -}}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}

View File

@ -54,5 +54,10 @@ class TestKeepalivedConfiguration(unittest.TestCase):
result = 'friends {\nbarney rubble\nbetty rubble\nfred flintstone\nwilma flintstone\n}\n'
self.renderTest(testdata, result)
def test_ordered_hashes(self):
testdata = [{'fred': 'flintstone'}, {'wilma': 'flintstone'}, {'barney': 'rubble'}, {'betty': 'rubble'}]
result = 'fred flintstone\nwilma flintstone\nbarney rubble\nbetty rubble\n'
self.renderTest(testdata, result)
if __name__ == '__main__':
unittest.main()