Commit afe2ab59 by Chris Jerdonek

Add a unit test for Locator.find_file().

parent 440064b0
......@@ -19,6 +19,9 @@ from pystache.tests.common import DATA_DIR, EXAMPLES_DIR, AssertExceptionMixin
from pystache.tests.data.views import SayHello
LOCATOR_DATA_DIR = os.path.join(DATA_DIR, 'locator')
class LocatorTests(unittest.TestCase, AssertExceptionMixin):
def _locator(self):
......@@ -87,6 +90,13 @@ class LocatorTests(unittest.TestCase, AssertExceptionMixin):
self.assertEqual(locator.make_file_name('foo', template_extension='bar'), 'foo.bar')
def test_find_file(self):
locator = Locator()
path = locator.find_file('template.txt', [LOCATOR_DATA_DIR])
expected_path = os.path.join(LOCATOR_DATA_DIR, 'template.txt')
self.assertEqual(path, expected_path)
def test_find_name(self):
locator = Locator()
path = locator.find_name(search_dirs=[EXAMPLES_DIR], template_name='simple')
......@@ -107,7 +117,7 @@ class LocatorTests(unittest.TestCase, AssertExceptionMixin):
locator = Locator()
dir1 = DATA_DIR
dir2 = os.path.join(DATA_DIR, 'locator')
dir2 = LOCATOR_DATA_DIR
self.assertTrue(locator.find_name(search_dirs=[dir1], template_name='duplicate'))
self.assertTrue(locator.find_name(search_dirs=[dir2], template_name='duplicate'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment