Fix tests

This commit is contained in:
Gabriel Augendre 2020-12-25 14:46:32 +01:00
parent f49791651b
commit b94d05902b
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
4 changed files with 10 additions and 12 deletions

View file

@ -10,7 +10,6 @@ secrets:
- ea931da1-9acd-47b0-b6c9-52b8b61c4647 # Ansible hosts file - ea931da1-9acd-47b0-b6c9-52b8b61c4647 # Ansible hosts file
- 5c948915-48c2-4542-8fc1-a5676f4d7126 # Deploy SSH key - 5c948915-48c2-4542-8fc1-a5676f4d7126 # Deploy SSH key
environment: environment:
TESTING: true
POETRY_VERSION: 1.1.4 POETRY_VERSION: 1.1.4
tasks: tasks:
- install_poetry: | - install_poetry: |

View file

@ -1,4 +1,5 @@
import pytest import pytest
from django.core.management import call_command
from django.utils import timezone from django.utils import timezone
from articles.models import Article, User from articles.models import Article, User
@ -40,3 +41,9 @@ def unpublished_article(author: User) -> Article:
slug="some-draft-article-slug", slug="some-draft-article-slug",
content="## some draft article markdown\n\n[a draft article link](https://article.com)", content="## some draft article markdown\n\n[a draft article link](https://article.com)",
) )
@pytest.fixture(autouse=True, scope="session")
def collect_static():
call_command("collectstatic", "--no-input", "--clear")
call_command("assets", "build", "--manifest", "django")

View file

@ -43,7 +43,6 @@ EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv("DEBUG", "true").lower() == "true" DEBUG = os.getenv("DEBUG", "true").lower() == "true"
TESTING = os.getenv("TESTING", "false").lower() == "true"
ALLOWED_HOSTS = ["localhost"] # Required for healthcheck ALLOWED_HOSTS = ["localhost"] # Required for healthcheck
if DEBUG: if DEBUG:
@ -161,14 +160,7 @@ USE_TZ = True
STATIC_URL = "/static/" STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "staticfiles" STATIC_ROOT = BASE_DIR / "staticfiles"
if TESTING:
# ManifestStaticFilesStorage requires collectstatic to be run
# and collectstatic is not run for tests
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage" STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
else:
STATICFILES_STORAGE = (
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
)
STATICFILES_FINDERS = [ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.FileSystemFinder",

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
set -euxo pipefail set -euxo pipefail
TESTING=true python -m pytest python -m pytest
pre-commit run --all-files pre-commit run --all-files
TESTING=true python manage.py makemigrations --check python manage.py makemigrations --check