wuttamess/tests/test_util.py
2024-11-20 10:29:31 -06:00

27 lines
673 B
Python

# -*- coding: utf-8; -*-
import os
from unittest import TestCase
from unittest.mock import MagicMock
from wuttamess import util as mod
class TestExists(TestCase):
def test_basic(self):
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')