feat: add util.mako_renderer()
function
This commit is contained in:
parent
4879887cb3
commit
c41d364e03
6 changed files with 63 additions and 2 deletions
tests
4
tests/files/bar/_sync.toml
Normal file
4
tests/files/bar/_sync.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
[files."baz"]
|
||||
renderer = 'mako'
|
||||
tags = ['baz']
|
1
tests/files/bar/baz
Normal file
1
tests/files/bar/baz
Normal file
|
@ -0,0 +1 @@
|
|||
machine_is_live = ${machine_is_live}
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
@ -12,3 +13,14 @@ class TestExists(TestCase):
|
|||
c = MagicMock()
|
||||
mod.exists(c, '/foo')
|
||||
c.run.assert_called_once_with('test -e /foo', warn=True)
|
||||
|
||||
|
||||
class TestMakoRenderer(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
c = MagicMock()
|
||||
renderer = mod.mako_renderer(c, env={'machine_is_live': True})
|
||||
here = os.path.dirname(__file__)
|
||||
path = os.path.join(here, 'files', 'bar', 'baz')
|
||||
rendered = renderer(path, vars={})
|
||||
self.assertEqual(rendered, 'machine_is_live = True')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue