Skip to content

Commit f02a791

Browse files
committed
change test
1 parent 7b4ae9c commit f02a791

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

test/asynchronous/test_encryption.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ async def test_init_kms_tls_options(self):
170170
# Error cases:
171171
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options={"kmip": 1})
172172
with self.assertRaisesRegex(TypeError, r'kms_tls_options\["kmip"\] must be a dict'):
173-
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
174-
await client.db.coll.insert_one({"encrypted": "test"})
173+
AsyncMongoClient(auto_encryption_opts=opts)
175174

176175
tls_opts: Any
177176
for tls_opts in [
@@ -181,14 +180,12 @@ async def test_init_kms_tls_options(self):
181180
]:
182181
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
183182
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
184-
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
185-
await client.db.coll.insert_one({"encrypted": "test"})
183+
AsyncMongoClient(auto_encryption_opts=opts)
186184
opts = AutoEncryptionOpts(
187185
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
188186
)
189187
with self.assertRaises(FileNotFoundError):
190-
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
191-
await client.db.coll.insert_one({"encrypted": "test"})
188+
AsyncMongoClient(auto_encryption_opts=opts)
192189
# Success cases:
193190
tls_opts: Any
194191
for tls_opts in [None, {}]:

test/test_encryption.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def test_init_kms_tls_options(self):
170170
# Error cases:
171171
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options={"kmip": 1})
172172
with self.assertRaisesRegex(TypeError, r'kms_tls_options\["kmip"\] must be a dict'):
173-
client = self.rs_or_single_client(auto_encryption_opts=opts)
174-
client.db.coll.insert_one({"encrypted": "test"})
173+
MongoClient(auto_encryption_opts=opts)
175174

176175
tls_opts: Any
177176
for tls_opts in [
@@ -181,14 +180,12 @@ def test_init_kms_tls_options(self):
181180
]:
182181
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
183182
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
184-
client = self.rs_or_single_client(auto_encryption_opts=opts)
185-
client.db.coll.insert_one({"encrypted": "test"})
183+
MongoClient(auto_encryption_opts=opts)
186184
opts = AutoEncryptionOpts(
187185
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
188186
)
189187
with self.assertRaises(FileNotFoundError):
190-
client = self.rs_or_single_client(auto_encryption_opts=opts)
191-
client.db.coll.insert_one({"encrypted": "test"})
188+
MongoClient(auto_encryption_opts=opts)
192189
# Success cases:
193190
tls_opts: Any
194191
for tls_opts in [None, {}]:

0 commit comments

Comments
 (0)