Exemple #1
0
 def test_get_template_dir(self):
     template_dir = get_template_dir()
     self.assertTrue(os.path.isdir(template_dir), 'template dir not found')
     file_suffixes_in_template_dir = [
         os.path.basename(f).split('.')[-1]
         for f in os.listdir(template_dir)
     ]
     self.assertTrue('html' in file_suffixes_in_template_dir)
Exemple #2
0
def get_template_as_string(view_name: str) -> str:
    '''
    Get the content of template ``view_name`` from the template directory as string.

    :param view_name: The name of the template file.
    :return: The contents of the template file as string.
    '''
    path = Path(get_template_dir()) / view_name
    return get_binary_from_file(str(path)).decode('utf-8')
Exemple #3
0
def get_template_as_string(view_name):
    path = os.path.join(get_template_dir(), view_name)
    return get_binary_from_file(path).decode('utf-8')
Exemple #4
0
def test_get_template_dir():
    template_dir = get_template_dir()
    assert template_dir.is_dir(), 'template dir not found'
    file_suffixes_in_template_dir = [f.suffix for f in template_dir.iterdir()]
    assert '.html' in file_suffixes_in_template_dir