Skip to content

Commit f551606

Browse files
committed
Re-add test_base with EncryptionTestCase
- Factor out common attributes (would be nice to do decorators too but looks like that requires __init_subclass_ shenanigans)
1 parent 9d4f42e commit f551606

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

tests/encryption_/test_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.test import TestCase
2+
3+
4+
class EncryptionTestCase(TestCase):
5+
databases = {"default", "encrypted"}
6+
maxDiff = None

tests/encryption_/test_fields.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
Patient,
2828
PatientRecord,
2929
)
30+
from .test_base import EncryptionTestCase
3031

3132

3233
@skipUnlessDBFeature("supports_queryable_encryption")
33-
class PatientModelTests(TestCase):
34-
databases = {"default", "encrypted"}
35-
34+
class PatientModelTests(EncryptionTestCase):
3635
def setUp(self):
3736
self.billing = Billing(cc_type="Visa", cc_number="4111111111111111")
3837
self.patient_record = PatientRecord(ssn="123-45-6789", billing=self.billing)

tests/encryption_/test_management.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from bson import json_util
44
from django.core.management import call_command
5-
from django.test import TestCase, modify_settings, skipUnlessDBFeature
5+
from django.test import modify_settings, skipUnlessDBFeature
6+
7+
from .test_base import EncryptionTestCase
68

79

810
@skipUnlessDBFeature("supports_queryable_encryption")
911
@modify_settings(INSTALLED_APPS={"prepend": "django_mongodb_backend"})
10-
class CommandTests(TestCase):
11-
databases = {"default", "encrypted"}
12-
maxDiff = None
13-
12+
class CommandTests(EncryptionTestCase):
1413
# Expected encrypted field maps for all Encrypted* models
1514
expected_maps = {
1615
"encryption__patientrecord": {

tests/encryption_/test_schema.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
from django.db import connections
2-
from django.test import TestCase
32

43
from . import models
4+
from .test_base import EncryptionTestCase
55

66

7-
class SchemaTests(TestCase):
8-
databases = {"default", "encrypted"}
9-
maxDiff = None
10-
7+
class SchemaTests(EncryptionTestCase):
118
# Expected encrypted fields map per model
129
expected_map = {
1310
"PatientRecord": {

0 commit comments

Comments
 (0)