Skip to content

Commit 31b24f6

Browse files
committed
Fix encrypted tests crashing on non-encrypted builds
1 parent a6aa8da commit 31b24f6

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

.github/workflows/encrypted_settings.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,3 @@
1515
},
1616
"KMS_CREDENTIALS": {},
1717
}
18-
19-
20-
class EncryptedRouter:
21-
def allow_migrate(self, db, app_label, model_name=None, **hints):
22-
# The encryption_ app's models are only created in the encrypted database.
23-
if app_label == "encryption_":
24-
return db == "encrypted"
25-
# Don't create other app's models in the encrypted database.
26-
if db == "encrypted":
27-
return False
28-
return None
29-
30-
def kms_provider(self, model, **hints):
31-
return "local"
32-
33-
34-
DATABASE_ROUTERS = [EncryptedRouter()]

.github/workflows/mongodb_settings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
DATABASES = {
1212
"default": {**db_settings, "NAME": "djangotests"},
1313
"other": {**db_settings, "NAME": "djangotests-other"},
14+
"encrypted": {},
1415
}
1516
else:
1617
DATABASES = {
@@ -25,9 +26,26 @@
2526
"NAME": "djangotests-other",
2627
"OPTIONS": {"directConnection": True},
2728
},
29+
"encrypted": {},
2830
}
2931

3032

33+
class EncryptedRouter:
34+
def allow_migrate(self, db, app_label, model_name=None, **hints):
35+
# The encryption_ app's models are only created in the encrypted
36+
# database.
37+
if app_label == "encryption_":
38+
return db == "encrypted"
39+
# Don't create other app's models in the encrypted database.
40+
if db == "encrypted":
41+
return False
42+
return None
43+
44+
def kms_provider(self, model, **hints):
45+
return "local"
46+
47+
48+
DATABASE_ROUTERS = [EncryptedRouter()]
3149
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
3250
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
3351
SECRET_KEY = "django_tests_secret_key"

0 commit comments

Comments
 (0)