コード例 #1
0
 def test_register_template_with_single_context(self):
     '''Ensure registering a template with a single non-list context'''
     def _c1():
         pass
     tmpl = templating.OSConfigTemplate(config_file='/tmp/foo',
                                        contexts=_c1)
     self.assertEquals(tmpl.contexts, [_c1])
コード例 #2
0
    def test_register_template_with_list_of_contexts(self):
        '''Ensure registering a template with a list of context generators'''
        def _c1():
            pass

        def _c2():
            pass
        tmpl = templating.OSConfigTemplate(config_file='/tmp/foo',
                                           contexts=[_c1, _c2])
        self.assertEquals(tmpl.contexts, [_c1, _c2])
コード例 #3
0
    def test_register_string_template_with_single_context(self):
        '''Template rendering from a provided string with a context'''
        def _c1():
            pass

        config_file = '/etc/confdir/custom-drop-in.conf'
        config_template = 'use: {{ key_available_in_c1 }}'
        tmpl = templating.OSConfigTemplate(config_file=config_file,
                                           contexts=_c1,
                                           config_template=config_template)

        self.assertEquals(tmpl.contexts, [_c1])
        self.assertEquals(tmpl.config_file, config_file)
        self.assertEquals(tmpl.config_template, config_template)