diff --git a/cookiecutter.json b/cookiecutter.json index d6d217ca4..2187b228c 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -33,6 +33,7 @@ "GCP", "None" ], + "use_behave_django": "n", "custom_bootstrap_compilation": "n", "use_compressor": "n", "use_celery": "n", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ff84f1806..1e5e8b6a0 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -279,6 +279,10 @@ def remove_node_dockerfile(): shutil.rmtree(os.path.join("compose", "local", "node")) +def remove_behave_django_files(): + shutil.rmtree('features') + + def main(): debug = "{{ cookiecutter.debug }}".lower() == "y" @@ -342,6 +346,9 @@ def main(): if "{{ cookiecutter.use_travisci }}".lower() == "n": remove_dottravisyml_file() + if "{{ cookiecutter.use_behave_django }}".lower() == "n": + remove_behave_django_files() + print(SUCCESS + "Project initialized, keep up the good work!" + TERMINATOR) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 41f0f46cf..3baa7ed7a 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -292,7 +292,12 @@ ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_ADAPTER = "{{cookiecutter.project_slug}}.users.adapters.AccountAdapter" # https://django-allauth.readthedocs.io/en/latest/configuration.html SOCIALACCOUNT_ADAPTER = "{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter" - +{% if cookiecutter.use_behave_django == 'y' -%} +# django-behave +# ------------------------------------------------------------------------------ +# https://behave-django.readthedocs.io +INSTALLED_APPS +=["behave_django"] +{%- endif%} {% if cookiecutter.use_compressor == 'y' -%} # django-compressor # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/features/my_features.feature b/{{cookiecutter.project_slug}}/features/my_features.feature new file mode 100644 index 000000000..06b7baa81 --- /dev/null +++ b/{{cookiecutter.project_slug}}/features/my_features.feature @@ -0,0 +1,6 @@ +Feature: showing off behave + + Scenario: run a simple test + Given we have behave installed + When we implement a test + Then behave will test it for us! diff --git a/{{cookiecutter.project_slug}}/features/steps/my_feature.py b/{{cookiecutter.project_slug}}/features/steps/my_feature.py new file mode 100644 index 000000000..dffc86e05 --- /dev/null +++ b/{{cookiecutter.project_slug}}/features/steps/my_feature.py @@ -0,0 +1,27 @@ +from behave import * + +use_step_matcher("re") + + +@given("we have behave installed") +def step_impl(context): + """ + :type context: behave.runner.Context + """ + raise NotImplementedError(u'STEP: Given we have behave installed') + + +@when("we implement a test") +def step_impl(context): + """ + :type context: behave.runner.Context + """ + raise NotImplementedError(u'STEP: When we implement a test') + + +@then("behave will test it for us!") +def step_impl(context): + """ + :type context: behave.runner.Context + """ + raise NotImplementedError(u'STEP: Then behave will test it for us!') diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index c1df0b84b..653feda05 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -14,7 +14,9 @@ psycopg2-binary==2.8.3 # https://github.com/psycopg/psycopg2 mypy==0.720 # https://github.com/python/mypy pytest==5.1.2 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar - +{%- if cookiecutter.use_behave_django == 'y' %} +behave-django==1.3.0 #https://github.com/behave/behave-django +{%- endif %} # Code quality # ------------------------------------------------------------------------------ flake8==3.7.8 # https://github.com/PyCQA/flake8