diff --git a/.travis.yml b/.travis.yml index 1be0b743..c2bcdf42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,13 @@ matrix: script: sh tests/test_docker.sh - name: Docker with Celery script: sh tests/test_docker.sh use_celery=y + - name: Bare metal + script: sh tests/test_bare.sh use_celery=y use_compressor=y + services: + - postgresql + - redis-server + env: + - CELERY_BROKER_URL=redis://localhost:6379/0 install: - pip install tox diff --git a/CHANGELOG.md b/CHANGELOG.md index f013aec9..5df2d3a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,39 @@ All enhancements and patches to Cookiecutter Django will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2019-07-09] +### Fixed +- Always use test settings in pytest (@danihodovic) +- Remove gunicorn from `INSTALLED_APPS` (@danihodovic) +- Remove `EMAIL_HOST` and `EMAIL_PORT` with locmem backend (@danihodovic) + +### Added +- Add `EMAIL_TIMEOUT` (@danihodovic) + +## [2019-06-22] +### Fixed +- Remove redundant template debug setting (@danihodovic) + +## [2019-06-19] +### Fixed +- Fix removal carriage returns in docker scripts (@timclaessens) + +## [2019-06-15] +### Fixed +- Issue with Pycharm setup for running things in Docker compose (@foarsitter) + +## [2019-06-06] +### Changed +- Update generated Travis config (@browniebroke) + +## [2019-06-03] +### Added +- Installed `django-celery-beat` to keep scheduled tasks in DB (@keyvanm) + +## [2019-05-28] +### Changed +- Use GCP acronym rather than inconsistent GCE/GCS (@tanoabeleyra) + ## [2019-05-27] ### Changed - Made cloud provider optional (@tanoabeleyra) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 7a9dbf79..0f9feea6 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -42,6 +42,7 @@ Listed in alphabetical order. Name Github Twitter ========================== ============================ ============== 18 `@dezoito`_ + 2O4 `@2O4`_ a7p `@a7p`_ Aaron Eikenberry `@aeikenberry`_ Adam Bogdał `@bogdal`_ @@ -65,8 +66,8 @@ Listed in alphabetical order. Ashley Camba Barclay Gauld `@yunti`_ Bartek `@btknu`_ - Ben Warren `@bwarren2`_ Ben Lopatin + Ben Warren `@bwarren2`_ Benjamin Abel Bert de Miranda `@bertdemiranda`_ Bo Lopker `@blopker`_ @@ -89,6 +90,7 @@ Listed in alphabetical order. Cullen Rhodes `@c-rhodes`_ Curtis St Pierre `@curtisstpierre`_ @cstpierre1388 Dan Shultz `@shultz`_ + Dani Hodovic `@danihodovic`_ Daniel Hepper `@dhepper`_ @danielhepper Daniele Tricoli `@eriol`_ David Díaz `@ddiazpinto`_ @DavidDiazPinto @@ -98,8 +100,8 @@ Listed in alphabetical order. Demetris Stavrou `@demestav`_ Denis Bobrov `@delneg`_ Denis Orehovsky `@apirobot`_ - Dónal Adams `@epileptic-fish`_ Diane Chen `@purplediane`_ @purplediane88 + Dónal Adams `@epileptic-fish`_ Dong Huynh `@trungdong`_ Emanuel Calso `@bloodpet`_ @bloodpet Eraldo Energy `@eraldo`_ @@ -130,10 +132,11 @@ Listed in alphabetical order. Keith Webber `@townie`_ Kevin A. Stone Kevin Ndung'u `@kevgathuku`_ + Keyvan Mosharraf `@keyvanm`_ Krzysztof Szumny `@noisy`_ Krzysztof Żuraw `@krzysztofzuraw`_ - Leonardo Jimenez `@xpostudio4`_ Leo Zhou `@glasslion`_ + Leonardo Jimenez `@xpostudio4`_ Lin Xianyi `@iynaix`_ Luis Nell `@originell`_ Lukas Klein @@ -152,6 +155,7 @@ Listed in alphabetical order. Meghan Heintz `@dot2dotseurat`_ Mesut Yılmaz `@myilmaz`_ Michael Gecht `@mimischi`_ @_mischi + Min ho Kim `@minho42`_ mozillazg `@mozillazg`_ Oleg Russkin `@rolep`_ Pablo `@oubiga`_ @@ -178,6 +182,7 @@ Listed in alphabetical order. Tano Abeleyra `@tanoabeleyra`_ Taylor Baldwin Théo Segonds `@show0k`_ + Tim Claessens `@timclaessens`_ Tim Freund `@timfreund`_ Tom Atkins `@knitatoms`_ Tom Offermann @@ -190,29 +195,39 @@ Listed in alphabetical order. Vlad Doster `@vladdoster`_ Will Farley `@goldhand`_ @g01dhand William Archinal `@archinal`_ + Xaver Y.R. Chen `@yrchen`_ @yrchen Yaroslav Halchenko ========================== ============================ ============== .. _@a7p: https://github.com/a7p +.. _@2O4: https://github.com/2O4 .. _@ad-m: https://github.com/ad-m .. _@adammsteele: https://github.com/adammsteele .. _@aeikenberry: https://github.com/aeikenberry +.. _@afrowave: https://github.com/afrowave +.. _@ahhda: https://github.com/ahhda .. _@alb3rto: https://github.com/alb3rto .. _@ameistad: https://github.com/ameistad .. _@amjith: https://github.com/amjith .. _@andor-pierdelacabeza: https://github.com/andor-pierdelacabeza +.. _@andresgz: https://github.com/andresgz .. _@antoniablair: https://github.com/antoniablair .. _@apirobot: https://github.com/apirobot .. _@archinal: https://github.com/archinal .. _@areski: https://github.com/areski .. _@arruda: https://github.com/arruda +.. _@bertdemiranda: https://github.com/bertdemiranda .. _@bittner: https://github.com/bittner .. _@bloodpet: https://github.com/bloodpet .. _@blopker: https://github.com/blopker .. _@bogdal: https://github.com/bogdal +.. _@brentpayne: https://github.com/brentpayne +.. _@btknu: https://github.com/btknu .. _@burhan: https://github.com/burhan +.. _@bwarren2: https://github.com/bwarren2 .. _@c-rhodes: https://github.com/c-rhodes .. _@caffodian: https://github.com/caffodian +.. _@canonnervio: https://github.com/canonnervio .. _@carlmjohnson: https://github.com/carlmjohnson .. _@catherinedevlin: https://github.com/catherinedevlin .. _@ccurvey: https://github.com/ccurvey @@ -222,109 +237,106 @@ Listed in alphabetical order. .. _@ChrisPappalardo: https://github.com/ChrisPappalardo .. _@chuckus: https://github.com/chuckus .. _@cmackenzie1: https://github.com/cmackenzie1 +.. _@cmargieson: https://github.com/cmargieson .. _@Collederas: https://github.com/Collederas .. _@curtisstpierre: https://github.com/curtisstpierre +.. _@dadokkio: https://github.com/dadokkio +.. _@danihodovic: https://github.com/danihodovic .. _@davitovmasyan: https://github.com/davitovmasyan .. _@ddiazpinto: https://github.com/ddiazpinto +.. _@delneg: https://github.com/delneg .. _@demestav: https://github.com/demestav .. _@dezoito: https://github.com/dezoito .. _@dhepper: https://github.com/dhepper .. _@dot2dotseurat: https://github.com/dot2dotseurat .. _@dsclementsen: https://github.com/dsclementsen .. _@durkode: https://github.com/durkode +.. _@Egregors: https://github.com/Egregors .. _@epileptic-fish: https://gihub.com/epileptic-fish .. _@eraldo: https://github.com/eraldo .. _@erfaan: https://github.com/erfaan +.. _@ericgroom: https://github.com/ericgroom .. _@eriol: https://github.com/eriol .. _@eyadsibai: https://github.com/eyadsibai .. _@flyudvik: https://github.com/flyudvik .. _@foarsitter: https://github.com/foarsitter .. _@garry-cairns: https://github.com/garry-cairns .. _@garrypolley: https://github.com/garrypolley -.. _@goldhand: https://github.com/goldhand .. _@glasslion: https://github.com/glasslion +.. _@goldhand: https://github.com/goldhand .. _@hackebrot: https://github.com/hackebrot .. _@hairychris: https://github.com/hairychris +.. _@hanaquadara: https://github.com/hanaquadara .. _@hendrikschneider: https://github.com/hendrikschneider .. _@hjwp: https://github.com/hjwp .. _@IanLee1521: https://github.com/IanLee1521 .. _@ikkebr: https://github.com/ikkebr .. _@iynaix: https://github.com/iynaix +.. _@jangeador: https://github.com/jangeador .. _@jazztpt: https://github.com/jazztpt +.. _@jcass77: https://github.com/jcass77 .. _@jleclanche: https://github.com/jleclanche .. _@juliocc: https://github.com/juliocc .. _@jvanbrug: https://github.com/jvanbrug .. _@ka7eh: https://github.com/ka7eh .. _@kaidokert: https://github.com/kaidokert .. _@kappataumu: https://github.com/kappataumu +.. _@keithjeb: https://github.com/keithjeb .. _@kevgathuku: https://github.com/kevgathuku +.. _@keyvanm: https://github.com/keyvanm .. _@knitatoms: https://github.com/knitatoms .. _@krzysztofzuraw: https://github.com/krzysztofzuraw -.. _@msaizar: https://github.com/msaizar .. _@MathijsHoogland: https://github.com/MathijsHoogland .. _@mattayes: https://github.com/mattayes -.. _@mknapper1: https://github.com/mknapper1 .. _@menzenski: https://github.com/menzenski -.. _@mostaszewski: https://github.com/mostaszewski .. _@mfwarren: https://github.com/mfwarren +.. _@MightySCollins: https://github.com/MightySCollins .. _@mimischi: https://github.com/mimischi +.. _@minho42: https://github.com/minho42 .. _@mjsisley: https://github.com/mjsisley -.. _@myilmaz: https://github.com/myilmaz +.. _@mknapper1: https://github.com/mknapper1 +.. _@mostaszewski: https://github.com/mostaszewski .. _@mozillazg: https://github.com/mozillazg +.. _@mrcoles: https://github.com/mrcoles +.. _@msaizar: https://github.com/msaizar +.. _@myilmaz: https://github.com/myilmaz .. _@noisy: https://github.com/noisy .. _@originell: https://github.com/originell .. _@oubiga: https://github.com/oubiga .. _@parbhat: https://github.com/parbhat +.. _@pchiquet: https://github.com/pchiquet +.. _@phiberjenz: https://github.com/phiberjenz +.. _@purplediane: https://github.com/purplediane .. _@raonyguimaraes: https://github.com/raonyguimaraes .. _@reggieriser: https://github.com/reggieriser .. _@rm--: https://github.com/rm-- +.. _@rolep: https://github.com/rolep .. _@romanosipenko: https://github.com/romanosipenko +.. _@saschalalala: https://github.com/saschalalala .. _@shireenrao: https://github.com/shireenrao .. _@show0k: https://github.com/show0k .. _@shultz: https://github.com/shultz .. _@siauPatrick: https://github.com/siauPatrick +.. _@sladinji: https://github.com/sladinji .. _@slafs: https://github.com/slafs .. _@ssteinerX: https://github.com/ssteinerx .. _@stepmr: https://github.com/stepmr .. _@suledev: https://github.com/suledev .. _@takkaria: https://github.com/takkaria +.. _@tanoabeleyra: https://github.com/tanoabeleyra +.. _@timclaessens: https://github.com/timclaessens .. _@timfreund: https://github.com/timfreund +.. _@townie: https://github.com/townie .. _@Travistock: https://github.com/Tavistock .. _@trungdong: https://github.com/trungdong .. _@Tubo: https://github.com/tubo +.. _@umrashrf: https://github.com/umrashrf .. _@viviangb: https://github.com/viviangb +.. _@vladdoster: https://github.com/vladdoster .. _@xpostudio4: https://github.com/xpostudio4 +.. _@yrchen: https://github.com/yrchen .. _@yunti: https://github.com/yunti .. _@zcho: https://github.com/zcho -.. _@phiberjenz: https://github.com/phiberjenz -.. _@sladinji: https://github.com/sladinji -.. _@andresgz: https://github.com/andresgz -.. _@jangeador: https://github.com/jangeador -.. _@townie: https://github.com/townie -.. _@MightySCollins: https://github.com/MightySCollins -.. _@dadokkio: https://github.com/dadokkio -.. _@bwarren2: https://github.com/bwarren2 -.. _@bertdemiranda: https://github.com/bertdemiranda -.. _@brentpayne: https://github.com/brentpayne -.. _@afrowave: https://github.com/afrowave -.. _@pchiquet: https://github.com/pchiquet -.. _@delneg: https://github.com/delneg -.. _@purplediane: https://github.com/purplediane -.. _@umrashrf: https://github.com/umrashrf -.. _@ahhda: https://github.com/ahhda -.. _@keithjeb: https://github.com/keithjeb -.. _@btknu: https://github.com/btknu -.. _@rolep: https://github.com/rolep -.. _@canonnervio: https://github.com/canonnervio -.. _@jcass77: https://github.com/jcass77 -.. _@Egregors: https://github.com/Egregors -.. _@saschalalala: https://github.com/saschalalala -.. _@mrcoles: https://github.com/mrcoles -.. _@ericgroom: https://github.com/ericgroom -.. _@hanaquadara: https://github.com/hanaquadara -.. _@vladdoster: https://github.com/vladdoster -.. _@cmargieson: https://github.com/cmargieson -.. _@tanoabeleyra: https://github.com/tanoabeleyra Special Thanks ~~~~~~~~~~~~~~ diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst index 4a16123a..53e98037 100644 --- a/docs/deployment-on-heroku.rst +++ b/docs/deployment-on-heroku.rst @@ -23,25 +23,25 @@ Run these commands to deploy the project to Heroku: heroku addons:create mailgun:starter heroku config:set PYTHONHASHSEED=random - + heroku config:set WEB_CONCURRENCY=4 - + heroku config:set DJANGO_DEBUG=False heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)" - - # Generating a 32 character-long random string without any of the visually similiar characters "IOl01": + + # Generating a 32 character-long random string without any of the visually similar characters "IOl01": heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/" - + # Set this to your Heroku app url, e.g. 'bionic-beaver-28392.herokuapp.com' heroku config:set DJANGO_ALLOWED_HOSTS= - + # Assign with AWS_ACCESS_KEY_ID heroku config:set DJANGO_AWS_ACCESS_KEY_ID= - + # Assign with AWS_SECRET_ACCESS_KEY heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY= - + # Assign with AWS_STORAGE_BUCKET_NAME heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME= diff --git a/docs/deployment-on-pythonanywhere.rst b/docs/deployment-on-pythonanywhere.rst index ea25b3ae..83b23b27 100644 --- a/docs/deployment-on-pythonanywhere.rst +++ b/docs/deployment-on-pythonanywhere.rst @@ -29,7 +29,7 @@ Once you've been through this one-off config, future deployments are much simple Getting your code and dependencies installed on PythonAnywhere -------------------------------------------------------------- -Make sure your project is fully commited and pushed up to Bitbucket or Github or wherever it may be. Then, log into your PythonAnywhere account, open up a **Bash** console, clone your repo, and create a virtualenv: +Make sure your project is fully committed and pushed up to Bitbucket or Github or wherever it may be. Then, log into your PythonAnywhere account, open up a **Bash** console, clone your repo, and create a virtualenv: .. code-block:: bash @@ -153,7 +153,7 @@ Back on the Web tab, hit **Reload**, and your app should be live! **NOTE:** *you may see security warnings until you set up your SSL certificates. If you -want to supress them temporarily, set DJANGO_SECURE_SSL_REDIRECT to blank. Follow +want to suppress them temporarily, set DJANGO_SECURE_SSL_REDIRECT to blank. Follow the instructions here to get SSL set up: https://help.pythonanywhere.com/pages/SSLOwnDomains/* diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 3434f68b..8694dde7 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -120,12 +120,12 @@ In production, we have Mailgun_ configured to have your back! Celery ------ + If the project is configured to use Celery as a task scheduler then by default tasks are set to run on the main thread -when developing locally. If you have the appropriate setup on your local machine then set +when developing locally. If you have the appropriate setup on your local machine then set the following +in ``config/settings/local.py``:: -CELERY_TASK_ALWAYS_EAGER = False - -in /config/settings/local.py + CELERY_TASK_ALWAYS_EAGER = False Sass Compilation & Live Reloading diff --git a/docs/testing.rst b/docs/testing.rst index 6ca21388..63cb9e18 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -19,9 +19,9 @@ You will get a readout of the `users` app that has already been set up with test If you set up your project to `develop locally with docker`_, run the following command: :: - $ docker-compose -f local.yml run django pytest + $ docker-compose -f local.yml run django pytest -Targetting particular apps for testing in ``docker`` follows a similar pattern as previously shown above. +Targeting particular apps for testing in ``docker`` follows a similar pattern as previously shown above. Coverage -------- @@ -36,9 +36,9 @@ Once the tests are complete, in order to see the code coverage, run the followin .. note:: - At the root of the project folder, you will find the `pytest.ini` file. You can use this to customize_ the ``pytest`` to your liking. + At the root of the project folder, you will find the `pytest.ini` file. You can use this to customize_ the ``pytest`` to your liking. - There is also the `.coveragerc`. This is the configuration file for the ``coverage`` tool. You can find out more about `configuring`_ ``coverage``. + There is also the `.coveragerc`. This is the configuration file for the ``coverage`` tool. You can find out more about `configuring`_ ``coverage``. .. seealso:: diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index e7bc1e39..91332f14 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -22,6 +22,10 @@ if hasattr(project_slug, "isidentifier"): project_slug.isidentifier() ), "'{}' project slug is not a valid Python identifier.".format(project_slug) +assert ( + project_slug == project_slug.lower() +), "'{}' project slug should be all lowercase".format(project_slug) + assert ( "\\" not in "{{ cookiecutter.author_name }}" ), "Don't include backslashes in author name." diff --git a/requirements.txt b/requirements.txt index d6049ecb..e5d371ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,13 +5,13 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ black==19.3b0 -flake8==3.7.7 +flake8==3.7.8 # Testing # ------------------------------------------------------------------------------ -tox==3.12.1 -pytest==4.6.0 -pytest_cases==1.6.3 -pytest-cookies==0.3.0 -pytest-xdist==1.28.0 -pyyaml==5.1 +tox==3.13.2 +pytest==5.0.1 +pytest_cases==1.10.1 +pytest-cookies==0.4.0 +pytest-xdist==1.29.0 +pyyaml==5.1.1 diff --git a/tests/test_bare.sh b/tests/test_bare.sh new file mode 100755 index 00000000..7021a7e4 --- /dev/null +++ b/tests/test_bare.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# this is a very simple script that tests the docker configuration for cookiecutter-django +# it is meant to be run from the root directory of the repository, eg: +# sh tests/test_docker.sh + +set -o errexit + +# install test requirements +pip install -r requirements.txt + +# create a cache directory +mkdir -p .cache/bare +cd .cache/bare + +# create the project using the default settings in cookiecutter.json +cookiecutter ../../ --no-input --overwrite-if-exists use_docker=n $@ +cd my_awesome_project + +# Install OS deps +sudo utility/install_os_dependencies.sh install + +# Install Python deps +pip install -r requirements/local.txt + +# run the project's tests +pytest diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 4292f989..77f71df5 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -2,6 +2,7 @@ import os import re import pytest +from cookiecutter.exceptions import FailedHookException from pytest_cases import pytest_fixture_plus import sh import yaml @@ -145,3 +146,14 @@ def test_travis_invokes_pytest(cookies, context): assert yaml.load(travis_yml)["script"] == ["pytest"] except yaml.YAMLError as e: pytest.fail(e) + + +@pytest.mark.parametrize("slug", ["project slug", "Project_Slug"]) +def test_invalid_slug(cookies, context, slug): + """Invalid slug should failed pre-generation hook.""" + context.update({"project_slug": slug}) + + result = cookies.bake(extra_context=context) + + assert result.exit_code != 0 + assert isinstance(result.exception, FailedHookException) diff --git a/{{cookiecutter.project_slug}}/.idea/workspace.xml b/{{cookiecutter.project_slug}}/.idea/workspace.xml new file mode 100644 index 00000000..a5d73c18 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.idea/workspace.xml @@ -0,0 +1,14 @@ + + + {%- if cookiecutter.use_celery == 'y' %} + + + {%- else %} + + + {%- endif %} + diff --git a/{{cookiecutter.project_slug}}/.idea/{{cookiecutter.project_slug}}.iml b/{{cookiecutter.project_slug}}/.idea/{{cookiecutter.project_slug}}.iml index 8ff6e388..d408765a 100644 --- a/{{cookiecutter.project_slug}}/.idea/{{cookiecutter.project_slug}}.iml +++ b/{{cookiecutter.project_slug}}/.idea/{{cookiecutter.project_slug}}.iml @@ -5,10 +5,10 @@ @@ -25,12 +25,12 @@ - - - -