Skip to content

Commit

Permalink
Make compatible with multi-db configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamHawtin committed Nov 27, 2024
1 parent 9f125fb commit 2a0fc49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cms/settings/functional_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import copy

from .base import * # noqa: F403 # pylint: disable=wildcard-import,unused-wildcard-import

# Debugging to be enabled locally only
Expand Down Expand Up @@ -33,5 +35,9 @@
# We don't need such a strong algorithm in tests, so use MD5
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

DATABASES = {"default": dj_database_url.config(default="postgres://ons:ons@localhost:15432/ons")} # noqa: F405
DATABASES = {
"default": dj_database_url.config(default="postgres://ons:ons@localhost:15432/ons"), # noqa: F405
}
DATABASES["read_replica"] = copy.deepcopy(DATABASES["default"])

REDIS_URL = "redis://localhost:16379"
3 changes: 3 additions & 0 deletions functional_tests/behave_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def django_test_case(context: Context) -> None:
# use of whitenoise for serving static content.
context.test_case_class = LiveServerTestCase

# Ensure the test case matches our multi DB configuration
context.test_case_class.databases = frozenset({"default", "read_replica"})

# The LiveServerTestCase setup will start a test server for our app, allowing us to test against a live app
context.test_case_class.setUpClass()

Expand Down

0 comments on commit 2a0fc49

Please sign in to comment.