2024-09-12 12:55:28 -05:00
|
|
|
# -*- coding: utf-8; -*-
|
|
|
|
|
2024-11-20 10:29:31 -06:00
|
|
|
import os
|
2024-09-12 12:55:28 -05:00
|
|
|
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)
|
2024-11-20 10:29:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
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')
|