Commits

Andriy Kornatskyy committed b90681b

Added unit tests for ChainLoader.

Comments (0)

Files changed (1)

src/wheezy/template/tests/test_loader.py

         """ Tests load if the name is not found.
         """
         assert None == self.loader.load('tmpl-x.html')
+
+
+class ChainLoaderTestCase(unittest.TestCase):
+    """ Test the ``ChainLoader``.
+    """
+
+    def setUp(self):
+        from wheezy.template.loader import ChainLoader
+        from wheezy.template.loader import DictLoader
+        self.loader = ChainLoader(loaders=[
+            DictLoader(templates={
+                'tmpl1.html': 'x1',
+            }),
+            DictLoader(templates={
+                'shared/master.html': 'x2'
+            })])
+
+    def test_list_names(self):
+        """ Tests list_names.
+        """
+        assert (
+            'tmpl1.html',
+            'shared/master.html'
+        ) == self.loader.list_names()
+
+    def test_load_existing(self):
+        """ Tests load.
+        """
+        assert 'x1' == self.loader.load('tmpl1.html')
+        assert 'x2' == self.loader.load('shared/master.html')
+
+    def test_load_not_found(self):
+        """ Tests load if the name is not found.
+        """
+        assert None == self.loader.load('tmpl-x.html')