Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the tests suite optional #123

Merged
merged 6 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"class_name_prefix": "{{ cookiecutter.domain_name | replace('_', ' ') | title | replace(' ', '') }}",
"github_user": "oncleben31",
"version": "0.0.0",
"test_suite": ["yes", "no"],
"_copy_without_render": [
".github/workflows/*.yml",
".github/workflows/*.yaml"
Expand Down
22 changes: 22 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#!/usr/bin/env python
import json
import os
import shutil
from pathlib import Path

REMOVE_PATHS = [
{% if cookiecutter.test_suite != "yes" %}
'tests/',
'requirements_dev.txt',
'requirements_test.txt',
'custom_components/__init__.py',
{% endif %}
]

def remove_path():
"""Remove some path according to cookiecutter parameters."""
for path in REMOVE_PATHS:
path = path.strip()
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)



def reindent_cookiecutter_json():
"""Indent .cookiecutter.json using two spaces.
Expand All @@ -22,3 +43,4 @@ def reindent_cookiecutter_json():

if __name__ == "__main__":
reindent_cookiecutter_json()
remove_path()
2 changes: 2 additions & 0 deletions {{cookiecutter.project_name}}/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ file.
You can use the `pre-commit` settings implemented in this repository to have
linting tool checking your contributions (see deicated section below).

{% if cookiecutter.test_suite == "yes" %}
You should also verify that existing [tests](./tests) are still working
and you are encouraged to add new ones.
You can run the tests using the following commands from the root folder:
Expand All @@ -79,6 +80,7 @@ pytest --durations=10 --cov-report term-missing --cov=custom_components.{{cookie

If any of the tests fail, make the necessary changes to the tests as part of
your changes to the integration.
{% endif %}

## Pre-commit

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ not_skip = __init__.py
force_sort_within_sections = true
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY
known_first_party = custom_components.{{ cookiecutter.domain_name }}, tests
known_first_party = custom_components.{{ cookiecutter.domain_name }}{% if cookiecutter.test_suite == "yes" %}, tests{% endif %}
combine_as_imports = true