|
1 | | -import os |
| 1 | +# Settings for django_mongodb_backend/tests. |
| 2 | +from django_settings import * # noqa: F403 |
2 | 3 |
|
3 | | -from pymongo.uri_parser import parse_uri |
4 | | - |
5 | | -if mongodb_uri := os.getenv("MONGODB_URI"): |
6 | | - db_settings = { |
7 | | - "ENGINE": "django_mongodb_backend", |
8 | | - "HOST": mongodb_uri, |
9 | | - } |
10 | | - # Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268 |
11 | | - uri = parse_uri(mongodb_uri) |
12 | | - if uri.get("username") and uri.get("password"): |
13 | | - db_settings["OPTIONS"] = {"tls": True, "tlsAllowInvalidCertificates": True} |
14 | | - DATABASES = { |
15 | | - "default": {**db_settings, "NAME": "djangotests"}, |
16 | | - "other": {**db_settings, "NAME": "djangotests-other"}, |
17 | | - } |
18 | | -else: |
19 | | - DATABASES = { |
20 | | - "default": { |
21 | | - "ENGINE": "django_mongodb_backend", |
22 | | - "NAME": "djangotests", |
23 | | - # Required when connecting to the Atlas image in Docker. |
24 | | - "OPTIONS": {"directConnection": True}, |
25 | | - }, |
26 | | - "other": { |
27 | | - "ENGINE": "django_mongodb_backend", |
28 | | - "NAME": "djangotests-other", |
29 | | - "OPTIONS": {"directConnection": True}, |
30 | | - }, |
31 | | - } |
32 | | - |
33 | | -DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" |
34 | | -PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",) |
35 | | -SECRET_KEY = "django_tests_secret_key" |
36 | | -USE_TZ = False |
| 4 | +DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"] |
0 commit comments