Skip to content

Commit 89a0c23

Browse files
committed
try again
1 parent f9cbb3d commit 89a0c23

File tree

5 files changed

+42
-41
lines changed

5 files changed

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

.github/workflows/encrypted_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Settings for django_mongodb_backend/tests when encryption is supported.
12
import os
23

34
from mongodb_settings import * # noqa: F403
Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
1-
import os
1+
# Settings for django_mongodb_backend/tests when encryption isn't supported.
2+
from django_settings import * # noqa: F403
23

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+
DATABASES["encrypted"] = {} # noqa: F405

.github/workflows/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
settings_module = (
181181
os.environ.get("DJANGO_SETTINGS_MODULE", "mongodb_settings")
182182
if app_name.endswith("_")
183-
else "mongodb_settings"
183+
else "django_settings"
184184
)
185185
res = os.system(run_tests_cmd % (app_name, settings_module)) # noqa: S605
186186
if res != 0:

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ unfixable = []
104104
exclude = []
105105
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"
106106

107-
[tool.ruff.lint.per-file-ignores]
108-
".github/workflows/mongodb_settings.py" = [
109-
"S105", # Possible hardcoded password assigned to: "SECRET_KEY"
110-
]
111-
112107
[tool.coverage.report]
113108
exclude_lines = [
114109
"if (.*and +)*_use_c( and.*)*:",

0 commit comments

Comments
 (0)