From b8393b4e8a9ebe2e516f16d18ba50cf2ad26ba9f Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 14 Oct 2026 08:24:59 -0400 Subject: [PATCH] update pymongocrypt test expectations for string preview --- bindings/python/test/test_mongocrypt.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bindings/python/test/test_mongocrypt.py b/bindings/python/test/test_mongocrypt.py index 1d5f51162..c8b8dc4c6 100644 --- a/bindings/python/test/test_mongocrypt.py +++ b/bindings/python/test/test_mongocrypt.py @@ -1064,8 +1064,8 @@ async def test_textPreview_query_fails(self): ) async def test_deprecated_preview_query_types(self): - # The "*Preview" query types remain as aliases to the GA names. - # PYTHON-5959 drops them. + # The "*Preview" query types error instead of aliasing to the GA + # names. MONGOCRYPT-938 drops them. key_path = "keys/ABCDEFAB123498761234123456789012-local-document.json" key_id = json_data(key_path)["_id"] encrypter = AsyncExplicitEncrypter( @@ -1091,10 +1091,12 @@ async def encrypt(query_type): for query_type in ["prefix", "suffix", "substring"]: with self.subTest(query_type=query_type): - self.assertEqual( - await encrypt(f"{query_type}Preview"), - await encrypt(query_type), - ) + # Expect error attempting to use '*Preview'. + with self.assertRaisesRegex( + MongoCryptError, + f"Query type '{query_type}Preview' is deprecated, please use '{query_type}'", + ): + await encrypt(f"{query_type}Preview") class TestNeedKMSAzureCredentials(unittest.TestCase): @@ -1591,8 +1593,8 @@ def test_textPreview_query_fails(self): ) def test_deprecated_preview_query_types(self): - # The "*Preview" query types remain as aliases to the GA names. - # PYTHON-5959 drops them. + # The "*Preview" query types error instead of aliasing to the GA + # names. MONGOCRYPT-938 drops them. key_path = "keys/ABCDEFAB123498761234123456789012-local-document.json" key_id = json_data(key_path)["_id"] encrypter = ExplicitEncrypter( @@ -1618,7 +1620,12 @@ def encrypt(query_type): for query_type in ["prefix", "suffix", "substring"]: with self.subTest(query_type=query_type): - self.assertEqual(encrypt(f"{query_type}Preview"), encrypt(query_type)) + # Expect error attempting to use '*Preview'. + with self.assertRaisesRegex( + MongoCryptError, + f"Query type '{query_type}Preview' is deprecated, please use '{query_type}'", + ): + encrypt(f"{query_type}Preview") def read(filename, **kwargs):