@@ -1234,7 +1234,9 @@ async def test_03_bulk_batch_split(self):
12341234 doc2 = {"_id" : "over_2mib_2" , "unencrypted" : "a" * _2_MiB }
12351235 self .listener .reset ()
12361236 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+ )
12381240
12391241 async def test_04_bulk_batch_split (self ):
12401242 limits_doc = json_data ("limits" , "limits-doc.json" )
@@ -1244,7 +1246,9 @@ async def test_04_bulk_batch_split(self):
12441246 doc2 .update (limits_doc )
12451247 self .listener .reset ()
12461248 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+ )
12481252
12491253 async def test_05_insert_succeeds_just_under_16MiB (self ):
12501254 doc = {"_id" : "under_16mib" , "unencrypted" : "a" * (_16_MiB - 2000 )}
@@ -1482,13 +1486,12 @@ class AzureGCPEncryptionTestMixin(AsyncEncryptionIntegrationTest):
14821486 KEYVAULT_COLL = "datakeys"
14831487 client : AsyncMongoClient
14841488
1485- async def asyncSetUp (self ):
1486- await super ().asyncSetUp ()
1487- self .client = self .simple_client ()
1489+ async def _setup (self ):
14881490 keyvault = self .client .get_database (self .KEYVAULT_DB ).get_collection (self .KEYVAULT_COLL )
14891491 await create_key_vault (keyvault , self .DEK )
14901492
14911493 async def _test_explicit (self , expectation ):
1494+ await self ._setup ()
14921495 client_encryption = self .create_client_encryption (
14931496 self .KMS_PROVIDER_MAP , # type: ignore[arg-type]
14941497 "." .join ([self .KEYVAULT_DB , self .KEYVAULT_COLL ]),
@@ -1506,6 +1509,7 @@ async def _test_explicit(self, expectation):
15061509 self .assertEqual (await client_encryption .decrypt (ciphertext ), "string0" )
15071510
15081511 async def _test_automatic (self , expectation_extjson , payload ):
1512+ await self ._setup ()
15091513 encrypted_db = "db"
15101514 encrypted_coll = "coll"
15111515 keyvault_namespace = "." .join ([self .KEYVAULT_DB , self .KEYVAULT_COLL ])
@@ -1543,10 +1547,10 @@ async def _test_automatic(self, expectation_extjson, payload):
15431547class TestAzureEncryption (AzureGCPEncryptionTestMixin , AsyncEncryptionIntegrationTest ):
15441548 @unittest .skipUnless (any (AZURE_CREDS .values ()), "Azure environment credentials are not set" )
15451549 async def asyncSetUp (self ):
1546- await super ().asyncSetUp ()
15471550 self .KMS_PROVIDER_MAP = {"azure" : AZURE_CREDS }
15481551 self .DEK = json_data (BASE , "custom" , "azure-dek.json" )
15491552 self .SCHEMA_MAP = json_data (BASE , "custom" , "azure-gcp-schema.json" )
1553+ await super ().asyncSetUp ()
15501554
15511555 async def test_explicit (self ):
15521556 return await self ._test_explicit (
@@ -1568,10 +1572,10 @@ async def test_automatic(self):
15681572class TestGCPEncryption (AzureGCPEncryptionTestMixin , AsyncEncryptionIntegrationTest ):
15691573 @unittest .skipUnless (any (GCP_CREDS .values ()), "GCP environment credentials are not set" )
15701574 async def asyncSetUp (self ):
1571- await super ().asyncSetUp ()
15721575 self .KMS_PROVIDER_MAP = {"gcp" : GCP_CREDS }
15731576 self .DEK = json_data (BASE , "custom" , "gcp-dek.json" )
15741577 self .SCHEMA_MAP = json_data (BASE , "custom" , "azure-gcp-schema.json" )
1578+ await super ().asyncSetUp ()
15751579
15761580 async def test_explicit (self ):
15771581 return await self ._test_explicit (
0 commit comments