Skip to content

Commit 7b4ae9c

Browse files
committed
fix test
1 parent a0fe2e5 commit 7b4ae9c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

test/asynchronous/test_encryption.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ def test_init_spawn_args(self):
166166
)
167167

168168
@unittest.skipUnless(_HAVE_PYMONGOCRYPT, "pymongocrypt is not installed")
169-
def test_init_kms_tls_options(self):
169+
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-
self.async_rs_or_single_client(auto_encryption_opts=opts)
173+
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
174+
await client.db.coll.insert_one({"encrypted": "test"})
174175

175176
tls_opts: Any
176177
for tls_opts in [
@@ -180,12 +181,14 @@ def test_init_kms_tls_options(self):
180181
]:
181182
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
182183
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
183-
self.async_rs_or_single_client(auto_encryption_opts=opts)
184+
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
185+
await client.db.coll.insert_one({"encrypted": "test"})
184186
opts = AutoEncryptionOpts(
185187
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
186188
)
187189
with self.assertRaises(FileNotFoundError):
188-
self.async_rs_or_single_client(auto_encryption_opts=opts)
190+
client = await self.async_rs_or_single_client(auto_encryption_opts=opts)
191+
await client.db.coll.insert_one({"encrypted": "test"})
189192
# Success cases:
190193
tls_opts: Any
191194
for tls_opts in [None, {}]:

test/test_encryption.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ 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-
self.rs_or_single_client(auto_encryption_opts=opts)
173+
client = self.rs_or_single_client(auto_encryption_opts=opts)
174+
client.db.coll.insert_one({"encrypted": "test"})
174175

175176
tls_opts: Any
176177
for tls_opts in [
@@ -180,12 +181,14 @@ def test_init_kms_tls_options(self):
180181
]:
181182
opts = AutoEncryptionOpts({}, "k.d", kms_tls_options=tls_opts)
182183
with self.assertRaisesRegex(ConfigurationError, "Insecure TLS options prohibited"):
183-
self.rs_or_single_client(auto_encryption_opts=opts)
184+
client = self.rs_or_single_client(auto_encryption_opts=opts)
185+
client.db.coll.insert_one({"encrypted": "test"})
184186
opts = AutoEncryptionOpts(
185187
{}, "k.d", kms_tls_options={"kmip": {"tlsCAFile": "does-not-exist"}}
186188
)
187189
with self.assertRaises(FileNotFoundError):
188-
self.rs_or_single_client(auto_encryption_opts=opts)
190+
client = self.rs_or_single_client(auto_encryption_opts=opts)
191+
client.db.coll.insert_one({"encrypted": "test"})
189192
# Success cases:
190193
tls_opts: Any
191194
for tls_opts in [None, {}]:

0 commit comments

Comments
 (0)