From b9871b5a86f75341fd29959e468027acf2d7cb96 Mon Sep 17 00:00:00 2001 From: Aayush Kataria Date: Fri, 13 Mar 2026 11:28:37 -0700 Subject: [PATCH 1/4] Fixing failing Full text policy test cases --- .../tests/test_full_text_policy.py | 32 ++++++++++++------- .../tests/test_full_text_policy_async.py | 32 ++++++++++++------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py index 2c3d883a7049..c88d2ead0435 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py @@ -83,7 +83,8 @@ def test_create_full_text_container(self): indexing_policy=indexing_policy ) properties = created_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] self.test_db.delete_container(created_container.id) @@ -97,7 +98,7 @@ def test_create_full_text_container(self): full_text_policy=full_text_policy_no_paths, ) properties = created_container.read() - assert properties["fullTextPolicy"] == full_text_policy_no_paths + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy_no_paths["defaultLanguage"] self.test_db.delete_container(created_container.id) # Create a container with a full text policy with a given path containing only default language @@ -115,7 +116,8 @@ def test_create_full_text_container(self): full_text_policy=full_text_policy_no_langs, ) properties = created_container.read() - assert properties["fullTextPolicy"] == full_text_policy_no_langs + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy_no_langs["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy_no_langs["fullTextPaths"] self.test_db.delete_container(created_container.id) def test_replace_full_text_container(self): @@ -149,7 +151,8 @@ def test_replace_full_text_container(self): indexing_policy=indexing_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] assert created_container_properties['indexingPolicy'] != properties['indexingPolicy'] self.test_db.delete_container(created_container.id) @@ -162,7 +165,8 @@ def test_replace_full_text_container(self): indexing_policy=indexing_policy ) created_container_properties = created_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] # Replace the container with new policies @@ -175,7 +179,8 @@ def test_replace_full_text_container(self): indexing_policy=indexing_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] assert created_container_properties['fullTextPolicy'] != properties['fullTextPolicy'] assert created_container_properties["indexingPolicy"] != properties["indexingPolicy"] @@ -342,7 +347,8 @@ def test_supported_languages_in_full_text_policy(self): full_text_policy=updated_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: self.test_db.delete_container(container.id) @@ -376,7 +382,8 @@ def test_default_language_fallback(self): full_text_policy=updated_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] # Insert and verify item item = { "id": str(uuid.uuid4()), @@ -429,7 +436,8 @@ def test_mismatched_default_and_path_languages(self): full_text_policy=updated_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: # Delete the container at the end of the test @@ -472,7 +480,8 @@ def test_replace_full_text_policy_with_different_languages(self): full_text_policy=updated_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: # Delete the container at the end of the test @@ -515,7 +524,8 @@ def test_replace_full_text_policy_with_different_path_languages(self): full_text_policy=updated_policy ) properties = replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: # Delete the container at the end of the test diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py index 378ce6138b81..fd208ed543e8 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py @@ -98,7 +98,8 @@ async def test_create_full_text_container_async(self): indexing_policy=indexing_policy ) properties = await created_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] await self.test_db.delete_container(created_container.id) @@ -112,7 +113,7 @@ async def test_create_full_text_container_async(self): full_text_policy=full_text_policy_no_paths, ) properties = await created_container.read() - assert properties["fullTextPolicy"] == full_text_policy_no_paths + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy_no_paths["defaultLanguage"] await self.test_db.delete_container(created_container.id) # Create a container with a full text policy with a given path containing only default language @@ -130,7 +131,8 @@ async def test_create_full_text_container_async(self): full_text_policy=full_text_policy_no_langs, ) properties = await created_container.read() - assert properties["fullTextPolicy"] == full_text_policy_no_langs + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy_no_langs["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy_no_langs["fullTextPaths"] async def test_replace_full_text_container_async(self): # Replace a container without a full text policy and full text indexing policy @@ -163,7 +165,8 @@ async def test_replace_full_text_container_async(self): indexing_policy=indexing_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] assert created_container_properties['indexingPolicy'] != properties['indexingPolicy'] await self.test_db.delete_container(created_container.id) @@ -176,7 +179,8 @@ async def test_replace_full_text_container_async(self): indexing_policy=indexing_policy ) created_container_properties = await created_container.read() - assert created_container_properties["fullTextPolicy"] == full_text_policy + assert created_container_properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert created_container_properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert created_container_properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] # Replace the container with new policies @@ -189,7 +193,8 @@ async def test_replace_full_text_container_async(self): indexing_policy=indexing_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == full_text_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] assert created_container_properties['fullTextPolicy'] != properties['fullTextPolicy'] assert created_container_properties["indexingPolicy"] != properties["indexingPolicy"] @@ -355,7 +360,8 @@ async def test_supported_languages_in_full_text_policy_async(self): full_text_policy=updated_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: await self.test_db.delete_container(container.id) @@ -387,7 +393,8 @@ async def test_default_language_fallback_async(self): full_text_policy=updated_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] item = { "id": str(uuid.uuid4()), "abstract": self.language_abstracts[language_code], @@ -439,7 +446,8 @@ async def test_mismatched_default_and_path_languages_async(self): full_text_policy=updated_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: await self.test_db.delete_container(container.id) @@ -522,7 +530,8 @@ async def test_replace_full_text_policy_with_different_languages_async(self): full_text_policy=updated_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: await self.test_db.delete_container(container.id) @@ -562,7 +571,8 @@ async def test_replace_full_text_policy_with_different_path_languages_async(self full_text_policy=updated_policy ) properties = await replaced_container.read() - assert properties["fullTextPolicy"] == updated_policy + assert properties["fullTextPolicy"]["defaultLanguage"] == updated_policy["defaultLanguage"] + assert properties["fullTextPolicy"]["fullTextPaths"] == updated_policy["fullTextPaths"] finally: await self.test_db.delete_container(container.id) From a534912de4a0934046942ecfb6d27001168b9899 Mon Sep 17 00:00:00 2001 From: Simon Moreno <30335873+simorenoh@users.noreply.github.com> Date: Fri, 13 Mar 2026 16:18:24 -0400 Subject: [PATCH 2/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py index c88d2ead0435..1005fc7aebda 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py @@ -165,9 +165,9 @@ def test_replace_full_text_container(self): indexing_policy=indexing_policy ) created_container_properties = created_container.read() - assert properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] - assert properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] - assert properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] + assert created_container_properties["fullTextPolicy"]["defaultLanguage"] == full_text_policy["defaultLanguage"] + assert created_container_properties["fullTextPolicy"]["fullTextPaths"] == full_text_policy["fullTextPaths"] + assert created_container_properties["indexingPolicy"]['fullTextIndexes'] == indexing_policy['fullTextIndexes'] # Replace the container with new policies full_text_policy['fullTextPaths'][0]['path'] = "/new_path" From a0c4a559590ecaa89fe263c38ea908ce17e8423d Mon Sep 17 00:00:00 2001 From: Aayush Kataria Date: Fri, 13 Mar 2026 16:08:44 -0700 Subject: [PATCH 3/4] Fixing failing Full text policy test cases --- sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py | 10 +++++++--- .../azure-cosmos/tests/test_full_text_policy_async.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py index 1005fc7aebda..1050384c203e 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py @@ -1,6 +1,7 @@ # The MIT License (MIT) # Copyright (c) Microsoft Corporation. All rights reserved. +import re import unittest import uuid @@ -206,7 +207,9 @@ def test_fail_create_full_text_policy(self): pytest.fail("Container creation should have failed for invalid path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an invalid Path: abstract" in e.http_error_message + assert re.search( + r"the full.text policy contains an invalid path.*abstract", + e.http_error_message, re.IGNORECASE) # Pass a full text policy with an unsupported default language full_text_policy_wrong_default = { @@ -279,8 +282,9 @@ def test_fail_create_full_text_indexing_policy(self): # pytest.fail("Container creation should have failed for lack of embedding policy.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The path of the Full Text Index /path does not match the path specified in the Full Text Policy"\ - in e.http_error_message + assert re.search( + r"the path of the full.text index.*does not match the path specified in the full.text policy", + e.http_error_message, re.IGNORECASE) # Pass a full text indexing policy with a wrongly formatted path indexing_policy_wrong_path = { diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py index fd208ed543e8..a16274e67fa5 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py @@ -1,6 +1,7 @@ # The MIT License (MIT) # Copyright (c) Microsoft Corporation. All rights reserved. +import re import unittest import uuid @@ -220,7 +221,9 @@ async def test_fail_create_full_text_policy_async(self): pytest.fail("Container creation should have failed for invalid path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an invalid Path: abstract" in e.http_error_message + assert re.search( + r"the full.text policy contains an invalid path.*abstract", + e.http_error_message, re.IGNORECASE) # Pass a full text policy with an unsupported default language full_text_policy_wrong_default = { @@ -293,8 +296,9 @@ async def test_fail_create_full_text_indexing_policy_async(self): # pytest.fail("Container creation should have failed for lack of embedding policy.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The path of the Full Text Index /path does not match the path specified in the Full Text Policy" \ - in e.http_error_message + assert re.search( + r"the path of the full.text index.*does not match the path specified in the full.text policy", + e.http_error_message, re.IGNORECASE) # Pass a full text indexing policy with a wrongly formatted path indexing_policy_wrong_path = { From 326e7945acb5c2b20268e63d5ea4e8401c35934a Mon Sep 17 00:00:00 2001 From: Aayush Kataria Date: Sat, 14 Mar 2026 09:42:42 -0700 Subject: [PATCH 4/4] Fixing failing Full text policy test cases --- .../tests/test_full_text_policy.py | 22 +++++++++++++------ .../tests/test_full_text_policy_async.py | 22 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py index 1050384c203e..2f739fcb5b34 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py @@ -230,8 +230,9 @@ def test_fail_create_full_text_policy(self): pytest.fail("Container creation should have failed for wrong supported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language spa-SPA. Supported languages are:"\ - in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language.*spa-SPA", + e.http_error_message, re.IGNORECASE) # Pass a full text policy with an unsupported path language full_text_policy_wrong_default = { @@ -252,8 +253,9 @@ def test_fail_create_full_text_policy(self): pytest.fail("Container creation should have failed for wrong supported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language spa-SPA. Supported languages are:"\ - in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language.*spa-SPA", + e.http_error_message, re.IGNORECASE) def test_fail_create_full_text_indexing_policy(self): full_text_policy = { @@ -302,7 +304,9 @@ def test_fail_create_full_text_indexing_policy(self): pytest.fail("Container creation should have failed for invalid path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "Full-text index specification at index (0) contains invalid path" in e.http_error_message + assert re.search( + r"full.text index specification at index \(0\) contains invalid path", + e.http_error_message, re.IGNORECASE) # Pass a full text indexing policy without a path field indexing_policy_no_path = { @@ -320,7 +324,9 @@ def test_fail_create_full_text_indexing_policy(self): pytest.fail("Container creation should have failed for missing path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "Missing path in full-text index specification at index (0)" in e.http_error_message + assert re.search( + r"missing path in full.text index specification at index \(0\)", + e.http_error_message, re.IGNORECASE) # Skipped until testing pipeline is set up for full text multi-language support @pytest.mark.skip @@ -625,7 +631,9 @@ def test_unsupported_language_in_full_text_policy(self): pytest.fail("Container replacement should have failed for unsupported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language" in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language", + e.http_error_message, re.IGNORECASE) finally: self.test_db.delete_container(container.id) diff --git a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py index a16274e67fa5..c962c5d398e8 100644 --- a/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py +++ b/sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py @@ -244,8 +244,9 @@ async def test_fail_create_full_text_policy_async(self): pytest.fail("Container creation should have failed for wrong supported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language spa-SPA. Supported languages are:" \ - in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language.*spa-SPA", + e.http_error_message, re.IGNORECASE) # Pass a full text policy with an unsupported path language full_text_policy_wrong_default = { @@ -266,8 +267,9 @@ async def test_fail_create_full_text_policy_async(self): pytest.fail("Container creation should have failed for wrong supported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language spa-SPA. Supported languages are:" \ - in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language.*spa-SPA", + e.http_error_message, re.IGNORECASE) async def test_fail_create_full_text_indexing_policy_async(self): full_text_policy = { @@ -316,7 +318,9 @@ async def test_fail_create_full_text_indexing_policy_async(self): pytest.fail("Container creation should have failed for invalid path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "Full-text index specification at index (0) contains invalid path" in e.http_error_message + assert re.search( + r"full.text index specification at index \(0\) contains invalid path", + e.http_error_message, re.IGNORECASE) # Pass a full text indexing policy without a path field indexing_policy_no_path = { @@ -334,7 +338,9 @@ async def test_fail_create_full_text_indexing_policy_async(self): pytest.fail("Container creation should have failed for missing path.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "Missing path in full-text index specification at index (0)" in e.http_error_message + assert re.search( + r"missing path in full.text index specification at index \(0\)", + e.http_error_message, re.IGNORECASE) # Skipped until testing pipeline is set up for full text multi-language support @pytest.mark.skip @@ -494,7 +500,9 @@ async def test_unsupported_language_in_full_text_policy_async(self): pytest.fail("Container replacement should have failed for unsupported language.") except exceptions.CosmosHttpResponseError as e: assert e.status_code == 400 - assert "The Full Text Policy contains an unsupported language" in e.http_error_message + assert re.search( + r"the full.text policy contains an unsupported language", + e.http_error_message, re.IGNORECASE) finally: await self.test_db.delete_container(container.id)