Skip to content

Commit c5bcea1

Browse files
committed
Rename/refactor tests, add stub connection test
1 parent 33b9b58 commit c5bcea1

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

tests/encryption_/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@skipUnlessDBFeature("supports_queryable_encryption")
1717
@override_settings(DATABASE_ROUTERS=[TestEncryptedRouter()])
18-
class QueryableEncryptionTestCase(TransactionTestCase):
18+
class QueryableEncryptionTests(TransactionTestCase):
1919
databases = {"default", "encrypted"}
2020
available_apps = ["encryption_"]
2121

tests/encryption_/test_connection.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from .test_base import QueryableEncryptionTests
2+
3+
4+
class TestConnection(QueryableEncryptionTests):
5+
def test_connection(self):
6+
# raise ImproperlyConfigured(
7+
# "Encrypted fields found but "
8+
# "DATABASES[[self.connection.alias}]['OPTIONS'] is missing "
9+
# "auto_encryption_opts. Please set `auto_encryption_opts` "
10+
# "in the connection settings."
11+
# )
12+
pass

tests/encryption_/test_fields.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from bson.binary import Binary
55
from django.conf import settings
66
from django.db import connections
7-
from django.test import override_settings
87

98
from .models import (
109
Appointment,
@@ -14,12 +13,10 @@
1413
PatientPortalUser,
1514
PatientRecord,
1615
)
17-
from .routers import TestEncryptedRouter
18-
from .test_base import QueryableEncryptionTestCase
16+
from .test_base import QueryableEncryptionTests
1917

2018

21-
@override_settings(DATABASE_ROUTERS=[TestEncryptedRouter()])
22-
class QueryableEncryptionFieldTests(QueryableEncryptionTestCase):
19+
class FieldTests(QueryableEncryptionTests):
2320
def test_appointment(self):
2421
self.assertEqual(Appointment.objects.get(time="8:00").time, time(8, 0))
2522

tests/encryption_/test_management.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
from bson import json_util
44
from django.core.management import call_command
5-
from django.test import modify_settings, override_settings
5+
from django.test import TransactionTestCase, modify_settings, override_settings, skipUnlessDBFeature
66

77
from .routers import TestEncryptedRouter
8-
from .test_base import QueryableEncryptionTestCase
98

109

10+
@skipUnlessDBFeature("supports_queryable_encryption")
1111
@modify_settings(
1212
INSTALLED_APPS={"prepend": "django_mongodb_backend"},
1313
)
1414
@override_settings(DATABASE_ROUTERS=[TestEncryptedRouter()])
15-
class QueryableEncryptionCommandTests(QueryableEncryptionTestCase):
15+
class CommandTests(TransactionTestCase):
1616
available_apps = ["django_mongodb_backend", "encryption_"]
1717
maxDiff = None
1818
expected_patient_record = {

tests/encryption_/test_schema.py

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

4-
from .routers import TestEncryptedRouter
5-
from .test_base import QueryableEncryptionTestCase
3+
from .test_base import QueryableEncryptionTests
64

75

8-
@override_settings(DATABASE_ROUTERS=[TestEncryptedRouter()])
9-
class QueryableEncryptionSchemaTests(QueryableEncryptionTestCase):
6+
class SchemaTests(QueryableEncryptionTests):
107
maxDiff = None
118

129
def test_get_encrypted_fields_map(self):

0 commit comments

Comments
 (0)