Commit aabb1c6b by Chris Jerdonek

Rename SpecLoader method to _find_relative().

parent ed896eb9
...@@ -141,8 +141,7 @@ class SpecLoader(object): ...@@ -141,8 +141,7 @@ class SpecLoader(object):
self.loader = loader self.loader = loader
self.search_dirs = search_dirs self.search_dirs = search_dirs
# TODO: make this private. def _find_relative(self, view):
def get_relative_template_location(self, view):
""" """
Return the relative template path as a (dir, file_name) pair. Return the relative template path as a (dir, file_name) pair.
...@@ -169,7 +168,7 @@ class SpecLoader(object): ...@@ -169,7 +168,7 @@ class SpecLoader(object):
Find and return the path to the template associated to the instance. Find and return the path to the template associated to the instance.
""" """
dir_path, file_name = self.get_relative_template_location(spec) dir_path, file_name = self._find_relative(spec)
# TODO: share code with the loader attribute here. # TODO: share code with the loader attribute here.
locator = Locator(extension=self.loader.extension) locator = Locator(extension=self.loader.extension)
......
...@@ -265,38 +265,38 @@ class TemplateSpecTests(unittest.TestCase): ...@@ -265,38 +265,38 @@ class TemplateSpecTests(unittest.TestCase):
def _assert_template_location(self, view, expected): def _assert_template_location(self, view, expected):
locator = self._make_locator() locator = self._make_locator()
actual = locator.get_relative_template_location(view) actual = locator._find_relative(view)
self.assertEquals(actual, expected) self.assertEquals(actual, expected)
def test_get_relative_template_location(self): def test_find_relative(self):
""" """
Test get_relative_template_location(): default behavior (no attributes set). Test _find_relative(): default behavior (no attributes set).
""" """
view = SampleView() view = SampleView()
self._assert_template_location(view, (None, 'sample_view.mustache')) self._assert_template_location(view, (None, 'sample_view.mustache'))
def test_get_relative_template_location__template_rel_path__file_name_only(self): def test_find_relative__template_rel_path__file_name_only(self):
""" """
Test get_relative_template_location(): template_rel_path attribute. Test _find_relative(): template_rel_path attribute.
""" """
view = SampleView() view = SampleView()
view.template_rel_path = 'template.txt' view.template_rel_path = 'template.txt'
self._assert_template_location(view, ('', 'template.txt')) self._assert_template_location(view, ('', 'template.txt'))
def test_get_relative_template_location__template_rel_path__file_name_with_directory(self): def test_find_relative__template_rel_path__file_name_with_directory(self):
""" """
Test get_relative_template_location(): template_rel_path attribute. Test _find_relative(): template_rel_path attribute.
""" """
view = SampleView() view = SampleView()
view.template_rel_path = 'foo/bar/template.txt' view.template_rel_path = 'foo/bar/template.txt'
self._assert_template_location(view, ('foo/bar', 'template.txt')) self._assert_template_location(view, ('foo/bar', 'template.txt'))
def test_get_relative_template_location__template_rel_directory(self): def test_find_relative__template_rel_directory(self):
""" """
Test get_relative_template_location(): template_rel_directory attribute. Test _find_relative(): template_rel_directory attribute.
""" """
view = SampleView() view = SampleView()
...@@ -304,18 +304,18 @@ class TemplateSpecTests(unittest.TestCase): ...@@ -304,18 +304,18 @@ class TemplateSpecTests(unittest.TestCase):
self._assert_template_location(view, ('foo', 'sample_view.mustache')) self._assert_template_location(view, ('foo', 'sample_view.mustache'))
def test_get_relative_template_location__template_name(self): def test_find_relative__template_name(self):
""" """
Test get_relative_template_location(): template_name attribute. Test _find_relative(): template_name attribute.
""" """
view = SampleView() view = SampleView()
view.template_name = 'new_name' view.template_name = 'new_name'
self._assert_template_location(view, (None, 'new_name.mustache')) self._assert_template_location(view, (None, 'new_name.mustache'))
def test_get_relative_template_location__template_extension(self): def test_find_relative__template_extension(self):
""" """
Test get_relative_template_location(): template_extension attribute. Test _find_relative(): template_extension attribute.
""" """
view = SampleView() view = SampleView()
...@@ -331,7 +331,7 @@ class TemplateSpecTests(unittest.TestCase): ...@@ -331,7 +331,7 @@ class TemplateSpecTests(unittest.TestCase):
view = SampleView() view = SampleView()
view.template_rel_path = 'foo/bar.txt' view.template_rel_path = 'foo/bar.txt'
self.assertTrue(locator.get_relative_template_location(view)[0] is not None) self.assertTrue(locator._find_relative(view)[0] is not None)
actual = locator._find(view) actual = locator._find(view)
expected = os.path.abspath(os.path.join(DATA_DIR, 'foo/bar.txt')) expected = os.path.abspath(os.path.join(DATA_DIR, 'foo/bar.txt'))
...@@ -346,7 +346,7 @@ class TemplateSpecTests(unittest.TestCase): ...@@ -346,7 +346,7 @@ class TemplateSpecTests(unittest.TestCase):
locator = self._make_locator() locator = self._make_locator()
view = SampleView() view = SampleView()
self.assertTrue(locator.get_relative_template_location(view)[0] is None) self.assertTrue(locator._find_relative(view)[0] is None)
actual = locator._find(view) actual = locator._find(view)
expected = os.path.abspath(os.path.join(DATA_DIR, 'sample_view.mustache')) expected = os.path.abspath(os.path.join(DATA_DIR, 'sample_view.mustache'))
......
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