Skip to content

Commit

Permalink
Trying cleaning up test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
brent-is-still-here committed Nov 14, 2024
1 parent ed12443 commit 85dcf8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
POSTGRES_DB: github_actions
ports:
- 5432:5432
# Add health check to ensure postgres is ready
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -37,11 +36,16 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements/dev.txt
- name: Create Recovery Key
run: |
python -c "from cryptography.fernet import Fernet; key = Fernet.generate_key(); open('recovery_key.key', 'wb').write(key)"
- name: Run Tests
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/github_actions
DJANGO_SETTINGS_MODULE: thebluelist.settings.test
DJANGO_SETTINGS_MODULE: config.settings.test
SECRET_KEY: your-test-secret-key-here
run: |
python manage.py test
python manage.py test -v 2
28 changes: 8 additions & 20 deletions config/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import dj_database_url
from .base import *

DEBUG = False

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
Expand All @@ -13,24 +13,12 @@
}
}

# Make sure all required apps are included
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
]

# Test-specific settings
DEBUG = False
# Test specific settings
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']

# Disable any expensive/unnecessary settings during testing
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.MD5PasswordHasher',
]
# Disable any resource-intensive settings
MAX_ACCOUNTS_PER_EMAIL = 2 # If you use this setting

# Add any other test-specific settings
# Override any settings that require external services
MAILTRAP_API_TOKEN = 'dummy-token-for-testing'

0 comments on commit 85dcf8b

Please sign in to comment.