예제 #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))
예제 #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))
예제 #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))
예제 #4
0
 def test_read_template_file(self):
     """Ensure ``read_template_file`` returns file content"""
     with tempfile.TemporaryDirectory() as tmpdir:
         filename = 'testfile'
         content = 'test'
         with open(os.path.join(tmpdir, filename), 'w') as f:
             f.write(content)
         test_content = tests.read_template_file(tmpdir, filename)
         self.assertEqual(test_content, content)
예제 #5
0
 def test_gh_actions_yes_yaml(self):
     """Ensure gh-actions 'yes' option builds with workflows CI file"""
     extra_context = {'gh_actions': 'yes'}
     builtdir = tests.bake_cookiecutter_template(
         output_dir=self.tmpdir, extra_context=extra_context)
     filename = '.github/workflows/ci-test-matrix.yml'
     ci_path = os.path.join(builtdir, filename)
     self.assertTrue(os.path.exists(ci_path))
     content = tests.read_template_file(builtdir, filename)
     self.assertTrue("cookiecutter" not in content)
예제 #6
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))
예제 #7
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))
예제 #8
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))