Example #1
0
 def test_gh_actions_no_badge(self):
     """Ensure travis 'no' option does not include badge in docs"""
     extra_context = {'gh_actions': 'no'}
     builtdir = tests.bake_cookiecutter_template(
         output_dir=self.tmpdir, extra_context=extra_context)
     readme_content = tests.read_template_file(builtdir, 'README.rst')
     self.assertTrue('.. image:: https://github.com/' not in readme_content)
     self.assertIsNone(tests.find_jinja_brackets(readme_content))
     conf_content = tests.read_template_file(builtdir, 'docs/conf.py')
     self.assertIsNone(tests.find_jinja_brackets(conf_content))
Example #2
0
 def test_tox_yes_pipfile(self):
     """Ensure tox 'yes' option adds tox install to ``Pipfile``"""
     extra_context = {'tox': 'yes'}
     builtdir = tests.bake_cookiecutter_template(
         output_dir=self.tmpdir, extra_context=extra_context)
     content = tests.read_template_file(builtdir, 'Pipfile')
     self.assertTrue('tox' in content)
     self.assertIsNone(tests.find_jinja_brackets(content))
Example #3
0
 def test_tox_yes_ini(self):
     """Ensure tox 'yes' option builds with ``tox.ini`` file"""
     extra_context = {'tox': 'yes'}
     builtdir = tests.bake_cookiecutter_template(
         output_dir=self.tmpdir, extra_context=extra_context)
     self.assertTrue(os.path.exists(os.path.join(builtdir, 'tox.ini')))
     content = tests.read_template_file(builtdir, 'tox.ini')
     self.assertIsNone(tests.find_jinja_brackets(content))
Example #4
0
 def test_find_jinja_brackets(self):
     """Ensure ``find_jinja_brackets`` finds all jinja bracket types"""
     strings = [
         "test {{ test }} test",
         "test {% test %} test",
         "test {# test #} test",
     ]
     for string in strings:
         self.assertTrue(tests.find_jinja_brackets(string))
Example #5
0
 def test_jinja_rendered_files(self):
     """Ensure no jinja brackets exist after rendering template files"""
     # loop through all template files for all sub-directories
     for subdir, dirs, files in os.walk(self.builtdir):
         for filename in files:
             if filename not in files_with_brackets_list:
                 file_content = tests.read_template_file(subdir, filename)
                 # assert no jinja brackets are present in rendered files
                 # add print statement to identify file if failure
                 print(filename)
                 self.assertIsNone(tests.find_jinja_brackets(file_content))
Example #6
0
 def test_license_not_open_source(self):
     """Ensure 'Not open source' license option builds correctly"""
     builtdir = tests.bake_cookiecutter_template(
         output_dir=self.tmpdir,
         extra_context={'license': "Not open source"})
     # confirm post_gen_project hook removes LICENSE file
     self.assertFalse(os.path.exists(os.path.join(builtdir, 'LICENSE')))
     # confirm setup.py generates correctly
     content = tests.read_template_file(builtdir, 'setup.py')
     # confirm that no license classifier is listed
     self.assertTrue('License ::' not in content)
     # confirm that file does not contain unrendered jinja
     self.assertIsNone(tests.find_jinja_brackets(content))
Example #7
0
 def test_license_open_source_options(self):
     """Ensure open source license options build correctly"""
     open_source_licenses = [
         license_name for license_name in license_list
         if license_name != "Not open source"
     ]
     # iterate through list of open source licenses and bake each cookie
     for license_name in open_source_licenses:
         with tempfile.TemporaryDirectory() as tempdir:
             builtdir = tests.bake_cookiecutter_template(
                 output_dir=tempdir,
                 extra_context={'license': license_name})
             # check the files affected by the license choice
             for filename in ['LICENSE', 'setup.py']:
                 content = tests.read_template_file(builtdir, filename)
                 # confirm that correct license name is listed in each file
                 self.assertTrue(license_name.lower() in content.lower())
                 # confirm that neither file contains unrendered jinja
                 self.assertIsNone(tests.find_jinja_brackets(content))
Example #8
0
 def test_jinja_rendered_dirs(self):
     """Ensire no jinja brackets exist after rendering directory names"""
     # loop through all template sub-directories
     for subdir, dirs, files in os.walk(self.builtdir):
         # assert no jinja brackets are present in rendered dirnames
         self.assertIsNone(tests.find_jinja_brackets(subdir))
Example #9
0
 def test_find_jinja_brackets_ignores_json(self):
     """Ensure ``find_jinja_brackets`` ignores json and dict brackets"""
     string = "{ test }"
     self.assertIsNone(tests.find_jinja_brackets(string))