Exemplo n.º 1
0
 def test_include_overwrites(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.yml").write("x: 1\ny: 2\n")
     tmpdir.join("b.yml").write(
         "x: 3\n" +
         "_includes:\n" +
         "  - 'a.yml'\n")
     assert m.read_yaml_file("b.yml") == {"x": 3, "y": 2}
Exemplo n.º 2
0
    def test_fake(self, tmpdir, monkeypatch):
        m = Mockdown(tmpdir.strpath)

        class FakeFake:
            def name(self):
                return "fake-name"
            def email(self):
                return "fake-email"

        monkeypatch.setattr(m, "get_fake", lambda filename: FakeFake())
        tmpdir.join("a.yml").write("name: {{fake.name()}}")
        assert m.read_yaml_file("a.yml") == {"name": "fake-name"}
Exemplo n.º 3
0
    def test_fake(self, tmpdir, monkeypatch):
        m = Mockdown(tmpdir.strpath)

        class FakeFake:
            def name(self):
                return "fake-name"

            def email(self):
                return "fake-email"

        monkeypatch.setattr(m, "get_fake", lambda filename: FakeFake())
        tmpdir.join("a.yml").write("name: {{fake.name()}}")
        assert m.read_yaml_file("a.yml") == {"name": "fake-name"}
Exemplo n.º 4
0
 def test_deep_include(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.yml").write("x: 1\ny: 2\n")
     tmpdir.join("b.yml").write("data: {{include('a.yml')}}")
     assert m.read_yaml_file("b.yml") == {"data": {"x": 1, "y": 2}}
Exemplo n.º 5
0
    def test_exists(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.exists("a.txt") is False

        tmpdir.join("a.txt").write("hello")
        assert m.exists("a.txt") is True
Exemplo n.º 6
0
 def test_render_template(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.html").write("Hello {{name}}")
     tmpdir.join("a.yml").write("name: Alice")
     assert m.render_template("a.html") == "Hello Alice"
Exemplo n.º 7
0
    def test_read_arguments(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.read_arguments("a.html") == {}

        tmpdir.join("a.yml").write("name: Alice")
        assert m.read_arguments("a.html") == {"name": "Alice"}
Exemplo n.º 8
0
    def read_yaml_file(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.read_yaml_file("a.yml") == {}

        tmpdir.join("a.yml").write("name: Alice")
        assert m.read_yaml_file("a.yml") == {"name": "Alice"}
Exemplo n.º 9
0
 def test_deep_include(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.yml").write("x: 1\ny: 2\n")
     tmpdir.join("b.yml").write("data: {{include('a.yml')}}")
     assert m.read_yaml_file("b.yml") == {"data": {"x": 1, "y": 2}}
Exemplo n.º 10
0
 def test_include_overwrites(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.yml").write("x: 1\ny: 2\n")
     tmpdir.join("b.yml").write("x: 3\n" + "_includes:\n" + "  - 'a.yml'\n")
     assert m.read_yaml_file("b.yml") == {"x": 3, "y": 2}
Exemplo n.º 11
0
    def test_exists(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.exists("a.txt") is False

        tmpdir.join("a.txt").write("hello")
        assert m.exists("a.txt") is True
Exemplo n.º 12
0
 def test_render_template(self, tmpdir):
     m = Mockdown(tmpdir.strpath)
     tmpdir.join("a.html").write("Hello {{name}}")
     tmpdir.join("a.yml").write("name: Alice")
     assert m.render_template("a.html") == "Hello Alice"
Exemplo n.º 13
0
    def test_read_arguments(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.read_arguments("a.html") == {}

        tmpdir.join("a.yml").write("name: Alice")
        assert m.read_arguments("a.html") == {"name": "Alice"}
Exemplo n.º 14
0
    def read_yaml_file(self, tmpdir):
        m = Mockdown(tmpdir.strpath)
        assert m.read_yaml_file("a.yml") == {}

        tmpdir.join("a.yml").write("name: Alice")
        assert m.read_yaml_file("a.yml") == {"name": "Alice"}