Fix tests
This commit is contained in:
parent
f49791651b
commit
b94d05902b
4 changed files with 10 additions and 12 deletions
|
@ -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: |
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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
|
||||||
|
|
Reference in a new issue