Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions bindings/python/test/test_mongocrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down Expand Up @@ -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(
Expand All @@ -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):
Expand Down
Loading