예제 #1
0
 def test_includes_work(self):
     self.add_path("test1", "hello world")
     contents = """
     {% include "test1" %}
     """
     self.assertEqual(
         render_string(self.context, contents, {})[0].strip(), "hello world")
예제 #2
0
 def test_for_loop(self):
     contents = """
     {% for f in foo %}{{ f }},{% endfor %}
     """
     args = {"foo": [1, 2, 3]}
     self.assertEqual(
         render_string(self.context, contents, args)[0].strip(), "1,2,3,")
예제 #3
0
 def test_allow_test_on_undefined(self):
     contents = """
     {% if foo %}
     hello
     {% endif %}
     """
     self.assertEqual(
         render_string(self.context, contents, {})[0].strip(), "")
예제 #4
0
 def test_includes_can_access_vars(self):
     self.add_path("test1", "hello {{ name }}")
     contents = """
     {% include "test1" %}
     """
     args = {"name": "world"}
     self.assertEqual(
         render_string(self.context, contents, args)[0].strip(), "hello world")
예제 #5
0
파일: patch.py 프로젝트: mitchellrj/yaybu
    def apply(self, context, output):
        name = self.resource.name.as_string()

        self.check_path(context, os.path.dirname(name), context.simulate)

        contents, sensitive = self.apply_patch(context, output)

        template_args = self.resource.template_args.resolve()
        if template_args:
            contents, secret = render_string(context, contents, template_args)
            sensitive = sensitive or secret

        fc = EnsureFile(name, contents, self.resource.owner.as_string(),
                        self.resource.group.as_string(),
                        self.resource.mode.resolve(), sensitive)
        context.change(fc)

        return fc.changed
예제 #6
0
파일: patch.py 프로젝트: yaybu/yaybu
    def apply(self, context, output):
        name = self.resource.name.as_string()

        self.check_path(context, os.path.dirname(name), context.simulate)

        contents, sensitive = self.apply_patch(context, output)

        template_args = self.resource.template_args.resolve()
        if template_args:
            contents, secret = render_string(context, contents, template_args)
            sensitive = sensitive or secret

        fc = EnsureFile(
            name,
            contents,
            self.resource.owner.as_string(),
            self.resource.group.as_string(),
            self.resource.mode.resolve(),
            sensitive,
        )
        context.change(fc)

        return fc.changed
예제 #7
0
 def test_simple_variable(self):
     args = {"hello": "world"}
     self.assertEqual(
         render_string(self.context, "{{ hello }}", args)[0].strip(), "world")
예제 #8
0
 def test_includes_tainted_by_secrets(self):
     self.add_path("test1", "hello: world\n", ['secret'])
     contents = """
     {% include "test1" %}
     """
     self.assertEqual(render_string(self.context, contents, {})[1], True)
예제 #9
0
 def test_includes_not_secret_by_default(self):
     self.add_path("test1", "hello: world\n")
     contents = """
     {% include "test1" %}
     """
     self.assertEqual(render_string(self.context, contents, {})[1], False)