@@ -1234,7 +1234,9 @@ async def test_03_bulk_batch_split(self):
1234
1234
doc2 = {"_id" : "over_2mib_2" , "unencrypted" : "a" * _2_MiB }
1235
1235
self .listener .reset ()
1236
1236
await self .coll_encrypted .bulk_write ([InsertOne (doc1 ), InsertOne (doc2 )])
1237
- self .assertEqual (self .listener .started_command_names (), ["insert" , "insert" ])
1237
+ self .assertEqual (
1238
+ len ([c for c in self .listener .started_command_names () if c == "insert" ]), 2
1239
+ )
1238
1240
1239
1241
async def test_04_bulk_batch_split (self ):
1240
1242
limits_doc = json_data ("limits" , "limits-doc.json" )
@@ -1244,7 +1246,9 @@ async def test_04_bulk_batch_split(self):
1244
1246
doc2 .update (limits_doc )
1245
1247
self .listener .reset ()
1246
1248
await self .coll_encrypted .bulk_write ([InsertOne (doc1 ), InsertOne (doc2 )])
1247
- self .assertEqual (self .listener .started_command_names (), ["insert" , "insert" ])
1249
+ self .assertEqual (
1250
+ len ([c for c in self .listener .started_command_names () if c == "insert" ]), 2
1251
+ )
1248
1252
1249
1253
async def test_05_insert_succeeds_just_under_16MiB (self ):
1250
1254
doc = {"_id" : "under_16mib" , "unencrypted" : "a" * (_16_MiB - 2000 )}
@@ -1482,13 +1486,12 @@ class AzureGCPEncryptionTestMixin(AsyncEncryptionIntegrationTest):
1482
1486
KEYVAULT_COLL = "datakeys"
1483
1487
client : AsyncMongoClient
1484
1488
1485
- async def asyncSetUp (self ):
1486
- await super ().asyncSetUp ()
1487
- self .client = self .simple_client ()
1489
+ async def _setup (self ):
1488
1490
keyvault = self .client .get_database (self .KEYVAULT_DB ).get_collection (self .KEYVAULT_COLL )
1489
1491
await create_key_vault (keyvault , self .DEK )
1490
1492
1491
1493
async def _test_explicit (self , expectation ):
1494
+ await self ._setup ()
1492
1495
client_encryption = self .create_client_encryption (
1493
1496
self .KMS_PROVIDER_MAP , # type: ignore[arg-type]
1494
1497
"." .join ([self .KEYVAULT_DB , self .KEYVAULT_COLL ]),
@@ -1506,6 +1509,7 @@ async def _test_explicit(self, expectation):
1506
1509
self .assertEqual (await client_encryption .decrypt (ciphertext ), "string0" )
1507
1510
1508
1511
async def _test_automatic (self , expectation_extjson , payload ):
1512
+ await self ._setup ()
1509
1513
encrypted_db = "db"
1510
1514
encrypted_coll = "coll"
1511
1515
keyvault_namespace = "." .join ([self .KEYVAULT_DB , self .KEYVAULT_COLL ])
@@ -1543,10 +1547,10 @@ async def _test_automatic(self, expectation_extjson, payload):
1543
1547
class TestAzureEncryption (AzureGCPEncryptionTestMixin , AsyncEncryptionIntegrationTest ):
1544
1548
@unittest .skipUnless (any (AZURE_CREDS .values ()), "Azure environment credentials are not set" )
1545
1549
async def asyncSetUp (self ):
1546
- await super ().asyncSetUp ()
1547
1550
self .KMS_PROVIDER_MAP = {"azure" : AZURE_CREDS }
1548
1551
self .DEK = json_data (BASE , "custom" , "azure-dek.json" )
1549
1552
self .SCHEMA_MAP = json_data (BASE , "custom" , "azure-gcp-schema.json" )
1553
+ await super ().asyncSetUp ()
1550
1554
1551
1555
async def test_explicit (self ):
1552
1556
return await self ._test_explicit (
@@ -1568,10 +1572,10 @@ async def test_automatic(self):
1568
1572
class TestGCPEncryption (AzureGCPEncryptionTestMixin , AsyncEncryptionIntegrationTest ):
1569
1573
@unittest .skipUnless (any (GCP_CREDS .values ()), "GCP environment credentials are not set" )
1570
1574
async def asyncSetUp (self ):
1571
- await super ().asyncSetUp ()
1572
1575
self .KMS_PROVIDER_MAP = {"gcp" : GCP_CREDS }
1573
1576
self .DEK = json_data (BASE , "custom" , "gcp-dek.json" )
1574
1577
self .SCHEMA_MAP = json_data (BASE , "custom" , "azure-gcp-schema.json" )
1578
+ await super ().asyncSetUp ()
1575
1579
1576
1580
async def test_explicit (self ):
1577
1581
return await self ._test_explicit (
0 commit comments