Skip to content

Commit f4df13a

Browse files
committed
feat: Add database configuration for integration tests
Add DATABASES and required Django apps to test_settings.py to support integration tests that use real ORM operations (wallet lifecycle tests). This change is necessary because: - Wallet tests verify model lifecycle (PENDING → ACTIVE → ERASED) - Tests verify ForeignKey relationships between Payment and Wallet - Tests verify database-level behavior (refresh_from_db, transactions) - Mock-based tests would not catch integration issues Following the pattern from testapp/settings.py, we use: - In-memory SQLite for speed - django.contrib.contenttypes (required for ForeignKey) - django.contrib.auth (common Django dependency) This is consistent with the pre-existing test structure where testapp provides real models for integration testing.
1 parent 2dacfb0 commit f4df13a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

test_settings.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44

5-
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), "payments"))
5+
PROJECT_ROOT = os.normpath(os.path.join(os.path.dirname(__file__), "payments"))
66
TEMPLATES = [
77
{
88
"BACKEND": "django.template.backends.django.DjangoTemplates",
@@ -13,4 +13,18 @@
1313
SECRET_KEY = "NOTREALLY"
1414
PAYMENT_HOST = "example.com"
1515

16-
INSTALLED_APPS = ["payments", "django.contrib.sites"]
16+
INSTALLED_APPS = [
17+
"payments",
18+
"django.contrib.sites",
19+
"django.contrib.contenttypes",
20+
"django.contrib.auth",
21+
]
22+
23+
# Database configuration for tests that use ORM operations
24+
# (e.g., wallet tests that verify model lifecycle and relationships)
25+
DATABASES = {
26+
"default": {
27+
"ENGINE": "django.db.backends.sqlite3",
28+
"NAME": ":memory:",
29+
}
30+
}

0 commit comments

Comments
 (0)