Skip to content

Commit

Permalink
Fix tests without collectstatic
Browse files Browse the repository at this point in the history
  • Loading branch information
craiga committed May 6, 2024
1 parent 2f71476 commit 3fb516e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/django.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
- name: Setup
run: |
pip install --requirement requirements.txt
- name: Collect Static Assets
run: python manage.py collectstatic --no-input
- name: Run Tests
run: make test

Expand Down
1 change: 1 addition & 0 deletions will_of_the_prophets/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
# https://github.com/jrief/django-sass-processor
"sass_processor.finders.CssFinder",
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"


# Ignore 404s
Expand Down
43 changes: 43 additions & 0 deletions will_of_the_prophets/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"""Fixtures used across tests."""

import logging
import os
from datetime import datetime
from unittest import mock

from django.test.utils import override_settings

import pytest
import pytz
from model_bakery import baker

logger = logging.getLogger(__name__)


@pytest.fixture
def rolls():
Expand All @@ -15,3 +22,39 @@ def rolls():
datetime(year=2369, month=7, day=number, hour=12, minute=34, second=56)
)
baker.make("Roll", number=number, embargo=embargo)


@pytest.fixture(scope="session", autouse=True)
def _set_settings():
"""Global settings for all tests."""
with override_settings(
AWS_S3_REGION_NAME="us-east-1",
CACHES={
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"TIMEOUT": 0,
}
},
DEBUG=False,
PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"],
SECURE_SSL_REDIRECT=True,
WHITENOISE_AUTOREFRESH=True,
STATICFILES_STORAGE="whitenoise.storage.CompressedStaticFilesStorage",
):
yield


@pytest.fixture(scope="session", autouse=True)
def _set_environment_variables():
"""Override global environment variables in all tests."""
with mock.patch.dict(
os.environ,
{
"AWS_ACCESS_KEY_ID": "testing",
"AWS_SECRET_ACCESS_KEY": "testing",
"AWS_SECURITY_TOKEN": "testing",
"AWS_SESSION_TOKEN": "testing",
"AWS_DEFAULT_REGION": "us-east-1",
},
):
yield
10 changes: 0 additions & 10 deletions will_of_the_prophets/tests/test_static_assets.py

This file was deleted.

0 comments on commit 3fb516e

Please sign in to comment.