Skip to content

Commit 2772aff

Browse files
committed
Test feature supports_queryable_encryption
1 parent c4d1c66 commit 2772aff

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

django_mongodb_backend/features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ def supports_transactions(self):
626626
return "setName" in hello or hello.get("msg") == "isdbgrid"
627627

628628
@cached_property
629-
def supports_encryption(self):
629+
def supports_queryable_encryption(self):
630630
"""
631-
Encryption is supported if the server is Atlas or Enterprise
631+
Queryable Encryption is supported if the server is Atlas or Enterprise
632632
and is configured as a replica set or sharded cluster.
633633
"""
634634
self.connection.ensure_connection()

tests/backend_/test_features.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,17 @@ def mocked_command(command):
4444

4545
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
4646
self.assertIs(connection.features.supports_transactions, False)
47+
48+
49+
class SupportsQueryableEncryptionTests(TestCase):
50+
# TODO: Add setUp? `del connection.features.supports_queryable_encryption` returns
51+
# `AttributeError: 'DatabasesFeatures' object has no attribute 'supports_queryable_encryption'`
52+
# even though it does have it upon inspection in `pdb`.
53+
def test_supports_queryable_encryption(self):
54+
def mocked_command(command):
55+
if command == "buildInfo":
56+
return {"modules": ["enterprise"]}
57+
raise Exception("Unexpected command")
58+
59+
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
60+
self.assertIs(connection.features.supports_queryable_encryption, True)

0 commit comments

Comments
 (0)