Fix #2249 -- Broken static files with whitenoise=n & cloud_prov… (#2252)

Fix #2249 -- Broken static files with whitenoise=n & cloud_provider=none
This commit is contained in:
Bruno Alla 2019-10-03 16:19:21 +01:00 committed by GitHub
commit 769b7bb882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -59,3 +59,12 @@ if "{{ cookiecutter.use_docker }}".lower() == "n":
)
+ TERMINATOR
)
if (
"{{ cookiecutter.use_whitenoise }}".lower() == "n"
and "{{ cookiecutter.cloud_provider }}" == "None"
):
print(
"You should either use Whitenoise or select a Cloud Provider to serve static files"
)
sys.exit(1)

View File

@ -49,6 +49,11 @@ def context_combination(
cloud_provider,
):
"""Fixture that parametrize the function where it's used."""
if cloud_provider == "None":
# Either of the two should be set for serving static files, so if cloud provider
# is not set, we force Whitenoise to be set
use_whitenoise = "y"
return {
"windows": windows,
"use_docker": use_docker,
@ -157,3 +162,12 @@ def test_invalid_slug(cookies, context, slug):
assert result.exit_code != 0
assert isinstance(result.exception, FailedHookException)
def test_no_whitenoise_and_no_cloud_provider(cookies, context):
"""It should not generate project if neither whitenoise or cloud provider are set"""
context.update({"use_whitenoise": "n", "cloud_provider": "None"})
result = cookies.bake(extra_context=context)
assert result.exit_code != 0
assert isinstance(result.exception, FailedHookException)