Skip to content

Commit 6d20e7b

Browse files
authored
Merge pull request #30 from aclark4life/main
Misc updates
2 parents 690a62a + 23182a7 commit 6d20e7b

File tree

11 files changed

+44
-48
lines changed

11 files changed

+44
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ uv.lock
3232
docs/_build/
3333
config/wagtail/wagtail_settings.py
3434
customer-master-key.txt
35+
mongocryptd.pid

config/allauth/allauth_settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
from django.contrib.auth.hashers import PBKDF2PasswordHasher
55

6-
from django_mongodb_cli.utils import get_databases
6+
import os
7+
import django_mongodb_backend
78

8-
9-
DATABASES = get_databases("allauth")
9+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
10+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
1011

1112
SECRET_KEY = "psst"
1213
SITE_ID = ObjectId()

config/debug_toolbar/debug_toolbar_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Django settings for tests."""
22

33
import os
4-
from django_mongodb_cli.utils import get_databases
4+
import django_mongodb_backend
55

6-
7-
DATABASES = get_databases("debug_toolbar")
6+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
7+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
88

99
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
1010

config/django/django_settings.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
from django_mongodb_cli.utils import get_databases
1+
import os
2+
import django_mongodb_backend
23

4+
kms_providers = django_mongodb_backend.get_kms_providers()
35

4-
DATABASES = get_databases("django")
6+
HOME = os.environ.get("HOME")
7+
8+
auto_encryption_opts = django_mongodb_backend.get_auto_encryption_opts(
9+
kms_providers=kms_providers,
10+
crypt_shared_lib_path=f"{HOME}/Downloads/mongo_crypt_shared_v1-macos-arm64-enterprise-8.0.10/lib/mongo_crypt_v1.dylib",
11+
)
12+
13+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
14+
DATABASES = {
15+
"default": django_mongodb_backend.parse_uri(DATABASE_URL),
16+
"encryption": django_mongodb_backend.parse_uri(
17+
DATABASE_URL, options={"auto_encryption_opts": auto_encryption_opts}
18+
),
19+
}
520

621
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
722
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)

config/extensions/debug_toolbar_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Django settings for tests."""
22

33
import os
4-
from django_mongodb_cli.utils import get_databases
4+
import django_mongodb_backend
55

6-
7-
DATABASES = get_databases("debug_toolbar")
6+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
7+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
88

99
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
1010

config/filter/filter_settings.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# ensure package/conf is importable
22
from django_filters.conf import DEFAULTS
33

4+
import os
5+
import django_mongodb_backend
46

5-
from django_mongodb_cli.utils import get_databases
6-
7-
8-
DATABASES = get_databases("django_filter")
9-
7+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
8+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
109

1110
INSTALLED_APPS = (
1211
"tests.mongo_apps.MongoContentTypesConfig",

config/rest_framework/rest_framework_settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
from bson import ObjectId
55
from django.core import management
66

7-
from django_mongodb_cli.utils import get_databases
7+
import django_mongodb_backend
8+
9+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
10+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
811

912

1013
def pytest_addoption(parser):
@@ -22,7 +25,7 @@ def pytest_configure(config):
2225

2326
settings.configure(
2427
DEBUG_PROPAGATE_EXCEPTIONS=True,
25-
DATABASES=get_databases("rest_framework"),
28+
DATABASES=DATABASES,
2629
SITE_ID=ObjectId("000000000000000000000001"),
2730
SECRET_KEY="not very secret in tests",
2831
USE_I18N=True,

config/wagtail/wagtail_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from django.utils.translation import gettext_lazy as _
77

88
from wagtail.test.numberformat import patch_number_formats
9-
from django_mongodb_cli.utils import get_databases
9+
10+
DATABASE_URL = os.environ.get("MONGODB_URI", "mongodb://localhost:27017/djangotests")
11+
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
1012

1113
WAGTAIL_CHECK_TEMPLATE_NUMBER_FORMAT = (
1214
os.environ.get("WAGTAIL_CHECK_TEMPLATE_NUMBER_FORMAT", "0") == "1"
@@ -25,8 +27,6 @@
2527

2628
TIME_ZONE = "Asia/Tokyo"
2729

28-
DATABASES = get_databases("wagtail")
29-
3030
SECRET_KEY = "not needed"
3131

3232
ROOT_URLCONF = "wagtail.test.urls"

django_mongodb_cli/utils.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@ def get_management_command(command=None):
7979
return base_command
8080

8181

82-
def get_databases(app):
83-
"""Get the databases configuration for the specified app."""
84-
import django_mongodb_backend
85-
86-
DATABASE_URL = os.environ.get(
87-
"MONGODB_URI", f"mongodb://localhost:27017/{app}_tests"
88-
)
89-
DATABASES = {"default": django_mongodb_backend.parse_uri(DATABASE_URL)}
90-
return DATABASES
91-
92-
9382
def get_repos(pyproject_path):
9483
with open(pyproject_path, "r") as f:
9584
pyproject_data = toml.load(f)

justfile

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
default:
22
echo 'Hello, world!'
33

4-
install: pip-install git-clone dev-install
4+
install: pip-install git-clone repo-install
55
alias i := install
66

7-
dev-install:
7+
repo-install:
88
dm repo install django
99
dm repo install django-mongodb-backend
10-
dm repo install django-mongodb-extensions
1110
dm repo install mongo-python-driver
12-
dm repo install python-xmlsec
13-
dm repo install libmongocrypt
14-
15-
16-
demo:
17-
dm repo test django queries_
18-
dm repo test django-filter tests.test_filters
19-
dm repo test django-debug-toolbar
20-
dm repo test django-allauth allauth/account/tests
21-
alias d := demo
2211

2312
# ---------------------------------------- git ----------------------------------------
2413

@@ -31,10 +20,7 @@ git-clone:
3120
dm repo clone django-mongodb-extensions
3221
dm repo clone django-mongodb-project
3322
dm repo clone django-mongodb-templates
34-
dm repo clone django-rest-framework
35-
dm repo clone libmongocrypt
3623
dm repo clone mongo-python-driver
37-
dm repo clone python-xmlsec
3824

3925
# ---------------------------------------- django ----------------------------------------
4026

@@ -111,6 +97,7 @@ sphinx-clean:
11197
alias sc := sphinx-clean
11298

11399
# ---------------------------------------- qe ----------------------------------------
100+
114101
qe:
115102
python qe.py
116103
alias q := qe

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies = [
1616
"python3-openid", # For django-allauth
1717
"python3-saml", # For django-allauth
1818
"pyjwt[crypto]", # For django-allauth
19+
"pymongocrypt", # For django-mongodb-backend QE
1920
"pytest",
2021
"pytest-html",
2122
"pytest-django", # For django-rest-framework and django-debug-toolbar

0 commit comments

Comments
 (0)