# Path: isomorphic/template/engine.py
# class JsEngine(Engine):
#     def __init__(self, dirs=None, app_dirs=False,
#                  allowed_include_roots=None, context_processors=None,
#                  debug=False, loaders=None, string_if_invalid='',
#                  file_charset='utf-8'):
# 
#         # Set the default loader to the JS loader
#         if loaders is None:
#             loaders = ['isomorphic.template.loaders.JsLoader']
#             if app_dirs:
#                 loaders += ['django.template.loaders.app_directories.Loader']
#                 app_dirs = False
# 
#         super(JsEngine, self).__init__(
#             dirs=dirs,
#             app_dirs=app_dirs,
#             allowed_include_roots=allowed_include_roots, context_processors=context_processors,
#             debug=debug, loaders=loaders, string_if_invalid=string_if_invalid,
#             file_charset=file_charset
#         )
# 
#     def get_template(self, template_name, dirs=_dirs_undefined):
#         if dirs is _dirs_undefined:
#             dirs = None
# 
#         template_path, origin = self.find_template(template_name, dirs)
#         return template_path
# 
# Path: isomorphic/template/loaders.py
# class JsLoader(Loader):
#     def load_template_source(self, template_name, template_dirs=None):
#         tried = []
#         for filepath in self.get_template_sources(template_name, template_dirs):
#             if exists(filepath):
#                 return filepath, None
#             else:
#                 tried.append(filepath)
# 
#         if tried:
#             error_msg = "Tried %s" % tried
#         else:
#             error_msg = ("Your template directories configuration is empty. "
#                          "Change it to point to at least one template directory.")
#         raise TemplateDoesNotExist(error_msg)
# 
#     def load_template(self, template_name, template_dirs=None):
#         """
#         Only the file path is returned
#         """
#         filepath, display_name = self.load_template_source(template_name, template_dirs)
#         return filepath, template_name


from django.conf import settings
from django.template import TemplateDoesNotExist
from django.test import TestCase
from isomorphic.template.engine import JsEngine
from isomorphic.template.loaders import JsLoader


class TestLoader(TestCase):
    def test_load_missing_template(self):
        engine = JsEngine(dirs=[settings.TEMPLATE_DIR])
        loader = JsLoader(engine)
        with self.assertRaises(TemplateDoesNotExist):
            loader.load_template_source('foo.js')

    def test_empty_template_dir_config(self):
        engine = JsEngine()

# Path: isomorphic/template/engine.py
# class JsEngine(Engine):
#     def __init__(self, dirs=None, app_dirs=False,
#                  allowed_include_roots=None, context_processors=None,
#                  debug=False, loaders=None, string_if_invalid='',
#                  file_charset='utf-8'):
# 
#         # Set the default loader to the JS loader
#         if loaders is None:
#             loaders = ['isomorphic.template.loaders.JsLoader']
#             if app_dirs:
#                 loaders += ['django.template.loaders.app_directories.Loader']
#                 app_dirs = False
# 
#         super(JsEngine, self).__init__(
#             dirs=dirs,
#             app_dirs=app_dirs,
#             allowed_include_roots=allowed_include_roots, context_processors=context_processors,
#             debug=debug, loaders=loaders, string_if_invalid=string_if_invalid,
#             file_charset=file_charset
#         )
# 
#     def get_template(self, template_name, dirs=_dirs_undefined):
#         if dirs is _dirs_undefined:
#             dirs = None
# 
#         template_path, origin = self.find_template(template_name, dirs)
#         return template_path
# 
# Path: isomorphic/template/loaders.py
# class JsLoader(Loader):
#     def load_template_source(self, template_name, template_dirs=None):
#         tried = []
#         for filepath in self.get_template_sources(template_name, template_dirs):
#             if exists(filepath):
#                 return filepath, None
#             else:
#                 tried.append(filepath)
# 
#         if tried:
#             error_msg = "Tried %s" % tried
#         else:
#             error_msg = ("Your template directories configuration is empty. "
#                          "Change it to point to at least one template directory.")
#         raise TemplateDoesNotExist(error_msg)
# 
#     def load_template(self, template_name, template_dirs=None):
#         """
#         Only the file path is returned
#         """
#         filepath, display_name = self.load_template_source(template_name, template_dirs)
#         return filepath, template_name


# Path: tests/test_loader.py
from django.conf import settings
from django.template import TemplateDoesNotExist
from django.test import TestCase
from isomorphic.template.engine import JsEngine
from isomorphic.template.loaders import JsLoader



class TestLoader(TestCase):
    def test_load_missing_template(self):
        engine = JsEngine(dirs=[settings.TEMPLATE_DIR])
        loader = JsLoader(engine)
        with self.assertRaises(TemplateDoesNotExist):
            loader.load_template_source('foo.js')

    def test_empty_template_dir_config(self):
        engine = JsEngine()

        loader = JsLoader(engine)