Skip to content

Commit e1ad85b

Browse files
committed
more query tests
1 parent 82b4c60 commit e1ad85b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.github/workflows/test-python-atlas.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
run: bash .github/workflows/start_local_atlas.sh mongodb/mongodb-atlas-local:8.0.15
5555
- name: Download crypt shared
5656
run: |
57-
wget https://downloads.mongodb.com/linux/mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.0.15.tgz
58-
tar -xvzf mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.0.15.tgz lib/mongo_crypt_v1.so
57+
wget https://downloads.mongodb.com/linux/mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.2.1.tgz
58+
tar -xvzf mongo_crypt_shared_v1-linux-x86_64-enterprise-ubuntu2404-8.2.1.tgz lib/mongo_crypt_v1.so
5959
ls -d "$PWD"/lib/mongo_crypt_v1.so
6060
- name: Run tests
6161
run: python3 django_repo/tests/runtests_.py

tests/encryption_/test_fields.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,27 +313,36 @@ def test_get_or_create(self):
313313
self.assertEqual(obj1, obj2)
314314

315315
def test_join(self):
316-
list(Book.objects.filter(author__name="xxx"))
316+
msg = (
317+
"Non-empty 'let' field is not allowed in the $lookup aggregation "
318+
"stage over an encrypted collection."
319+
)
320+
with self.assertRaisesMessage(DatabaseError, msg):
321+
list(Book.objects.filter(author__name="xxx"))
317322

318323
def test_order_by(self):
319324
msg = "Cannot add an encrypted field as a prefix of another encrypted field"
320325
with self.assertRaisesMessage(DatabaseError, msg):
321326
list(CharModel.objects.order_by("value"))
322327

323328
def test_select_related(self):
324-
list(Book.objects.select_related("author"))
329+
msg = (
330+
"Non-empty 'let' field is not allowed in the $lookup aggregation "
331+
"stage over an encrypted collection."
332+
)
333+
with self.assertRaisesMessage(DatabaseError, msg):
334+
list(Book.objects.select_related("author"))
325335

326336
def test_update(self):
327337
msg = "Multi-document updates are not allowed with Queryable Encryption"
328338
with self.assertRaisesMessage(DatabaseError, msg):
329339
self.assertEqual(CharModel.objects.update(value="xyz"), 1)
330340

331341
def test_update_or_create(self):
332-
# TODO
333-
# msg = "Multi-document updates are not allowed with Queryable Encryption"
334-
# with self.assertRaisesMessage(DatabaseError, msg):
335-
# obj, created = CharModel.objects.update_or_create(value="xyz"), 1)
336-
pass
342+
CharModel.objects.create(value="xyz")
343+
msg = "Multi-document updates are not allowed with Queryable Encryption"
344+
with self.assertRaisesMessage(DatabaseError, msg):
345+
CharModel.objects.update_or_create(value="xyz", defaults={"plain": "abc"})
337346

338347
def test_union(self):
339348
msg = "Aggregation stage $unionWith is not allowed or supported with automatic encryption."

0 commit comments

Comments
 (0)