Skip to content

Commit 819058a

Browse files
committed
Update tests and remove test router
- There is now one test "test_encrypted_fields_map", more to come. - Routing is done in the Django test suite settings.
1 parent 1771f56 commit 819058a

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

tests/encryption_/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
class Person(EncryptedModel):
88
name = models.CharField("name", max_length=100)
99
ssn = EncryptedCharField("ssn", max_length=11, queries=["equality"])
10-
ssn2 = EncryptedCharField("ssn", max_length=11, queries=["equality"])
1110

1211
class Meta:
1312
required_db_features = {"supports_queryable_encryption"}

tests/encryption_/routers.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/encryption_/tests.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
from django.db import connection
2-
from django.test import TestCase, override_settings
2+
from django.test import TestCase
33

44
from .models import Person
5-
from .routers import EncryptedRouter
65

76

8-
@override_settings(DATABASE_ROUTERS=[EncryptedRouter()])
97
class EncryptedModelTests(TestCase):
108
databases = {"default", "encrypted"}
119

1210
@classmethod
1311
def setUpTestData(cls):
1412
cls.person = Person(ssn="123-45-6789")
1513

16-
def test_encrypted_fields_map_on_instance(self):
14+
def test_encrypted_fields_map(self):
15+
""" """
1716
expected = {
18-
"fields": {
19-
"ssn": "EncryptedCharField",
20-
}
17+
"fields": [
18+
{"path": "ssn", "bsonType": "string", "queries": [{"queryType": "equality"}]}
19+
]
2120
}
2221
with connection.schema_editor() as editor:
2322
self.assertEqual(editor._get_encrypted_fields_map(self.person), expected)
24-
25-
def test_non_encrypted_fields_not_included(self):
26-
with connection.schema_editor() as editor:
27-
encrypted_field_names = editor._get_encrypted_fields_map(self.person).get("fields")
28-
self.assertNotIn("name", encrypted_field_names)

0 commit comments

Comments
 (0)