File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -581,9 +581,17 @@ def supports_atlas_search(self):
581
581
@cached_property
582
582
def supports_queryable_encryption (self ):
583
583
"""
584
- Queryable Encryption is supported if the server is Atlas or Enterprise.
584
+ Queryable Encryption is supported if the server is Atlas or Enterprise
585
+ and if pymongocrypt is installed.
585
586
"""
586
587
self .connection .ensure_connection ()
587
588
client = self .connection .connection .admin
588
589
build_info = client .command ("buildInfo" )
589
- return "enterprise" in build_info .get ("modules" )
590
+ is_enterprise = "enterprise" in build_info .get ("modules" )
591
+ try :
592
+ import pymongocrypt # noqa: F401
593
+
594
+ has_pymongocrypt = True
595
+ except ImportError :
596
+ has_pymongocrypt = False
597
+ return is_enterprise and has_pymongocrypt
Original file line number Diff line number Diff line change 2
2
3
3
import pymongo
4
4
from django .core .exceptions import ImproperlyConfigured
5
- from django .test import SimpleTestCase
5
+ from django .test import SimpleTestCase , TestCase , skipUnlessDBFeature
6
6
7
7
from django_mongodb_backend import get_auto_encryption_options , parse_uri
8
8
@@ -95,5 +95,10 @@ def test_no_scheme(self):
95
95
with self .assertRaisesMessage (pymongo .errors .InvalidURI , "Invalid URI scheme" ):
96
96
parse_uri ("cluster0.example.mongodb.net" )
97
97
98
+
99
+ # TODO: This can go in `test_features` once transaction support is added.
100
+ class ParseUriOptionsTests (TestCase ):
101
+ @skipUnlessDBFeature ("supports_queryable_encryption" )
98
102
def test_queryable_encryption_config (self ):
99
- get_auto_encryption_options ()
103
+ auto_encryption_options = get_auto_encryption_options ()
104
+ self .assertEqual (auto_encryption_options ._key_vault_namespace , "encryption.__keyVault" )
You can’t perform that action at this time.
0 commit comments