Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 21 additions & 11 deletions sdk/cosmos/azure-cosmos/tests/test_full_text_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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']
Comment thread
simorenoh marked this conversation as resolved.
Outdated

# Replace the container with new policies
Expand All @@ -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"]
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 21 additions & 11 deletions sdk/cosmos/azure-cosmos/tests/test_full_text_policy_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
Loading