Skip to content

Commit e6b95f6

Browse files
authored
PYTHON-4673 - Add Async Encryption Tests (mongodb#1818)
1 parent a2059dc commit e6b95f6

File tree

7 files changed

+3353
-183
lines changed

7 files changed

+3353
-183
lines changed

pymongo/asynchronous/encryption.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
_HAVE_PYMONGOCRYPT = True
5151
except ImportError:
5252
_HAVE_PYMONGOCRYPT = False
53-
MongoCryptCallback = object
53+
AsyncMongoCryptCallback = object
5454

5555
from bson import _dict_to_bson, decode, encode
5656
from bson.binary import STANDARD, UUID_SUBTYPE, Binary
@@ -207,10 +207,10 @@ async def collection_info(
207207
208208
:return: The first document from the listCollections command response as BSON.
209209
"""
210-
async with self.client_ref()[database].list_collections(
210+
async with await self.client_ref()[database].list_collections(
211211
filter=RawBSONDocument(filter)
212212
) as cursor:
213-
for doc in cursor:
213+
async for doc in cursor:
214214
return _dict_to_bson(doc, False, _DATA_KEY_OPTS)
215215
return None
216216

pymongo/asynchronous/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ async def command(
297297
)
298298

299299
if client and client._encrypter and reply:
300-
decrypted = client._encrypter.decrypt(reply.raw_command_response())
300+
decrypted = await client._encrypter.decrypt(reply.raw_command_response())
301301
response_doc = cast(
302302
"_DocumentOut", _decode_all_selective(decrypted, codec_options, user_fields)[0]
303303
)

pymongo/asynchronous/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async def run_operation(
309309
client = operation.client # type: ignore[assignment]
310310
if client and client._encrypter:
311311
if use_cmd:
312-
decrypted = client._encrypter.decrypt(reply.raw_command_response())
312+
decrypted = await client._encrypter.decrypt(reply.raw_command_response())
313313
docs = _decode_all_selective(decrypted, operation.codec_options, user_fields)
314314

315315
response: Response

pymongo/synchronous/mongo_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ def close(self) -> None:
15381538

15391539
if not _IS_SYNC:
15401540
# Add support for contextlib.closing.
1541-
aclose = close
1541+
close = close
15421542

15431543
def _get_topology(self) -> Topology:
15441544
"""Get the internal :class:`~pymongo.topology.Topology` object.

0 commit comments

Comments
 (0)