Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2cb0a5
Added Cross partition query tests for sync and async APIs
kushagraThapar Dec 1, 2023
a3fcabb
Added license header for new files
kushagraThapar Dec 1, 2023
bc81ab2
Updated database and container creation
kushagraThapar Dec 4, 2023
187b3d2
Updated python tests with setup and tear down
kushagraThapar Dec 8, 2023
f589e48
Fixed some tests cases
kushagraThapar Dec 8, 2023
40cf21e
Fixed spelling
kushagraThapar Dec 8, 2023
998b997
Added emulator CI
kushagraThapar Dec 12, 2023
f7d9ca4
Merged latest main and resolved conflicts
kushagraThapar Jan 12, 2024
cbaf26e
Removed python 3.7 emulator tests config
kushagraThapar Jan 12, 2024
d1434ae
Removed collection crud tests from emulator
kushagraThapar Jan 17, 2024
ade8a78
Merged latest main and resolved conflicts
kushagraThapar Jan 17, 2024
c7ccc22
Updated some collection heavy tests to skip for emulator
kushagraThapar Jan 17, 2024
cafc996
Fixing python 3.10
kushagraThapar Jan 18, 2024
b763f8b
Marking test_computed_properties async test to run only in live tests
kushagraThapar Jan 22, 2024
d95157a
Merge branch 'main' into azure_cosmos_add_cross_partition_query_tests
kushagraThapar Jan 22, 2024
7a34c7e
Fixed emulator tests with pytest fixtures
kushagraThapar Jan 29, 2024
c05e65c
Fixed more emulator tests with pytest fixtures
kushagraThapar Jan 30, 2024
6252619
Fixed more emulator tests with pytest fixtures
kushagraThapar Jan 31, 2024
420d639
Fixed more emulator tests with pytest fixtures and updated azure core…
kushagraThapar Feb 1, 2024
acbb98a
Fixed flaky tests
kushagraThapar Feb 1, 2024
a64f69c
Updated stored procedure create calls
kushagraThapar Feb 1, 2024
06d708c
Fixing sproc test
kushagraThapar Feb 2, 2024
1b85744
Fixing trigger test
kushagraThapar Feb 2, 2024
9b93a8f
Fixing flaky live ci tests
kushagraThapar Feb 5, 2024
499ef27
Fixing max parallel and removed python 3.11 for cosmos emulator windo…
kushagraThapar Feb 5, 2024
8198961
Added MIT license header
kushagraThapar Feb 7, 2024
b51d6f6
Update sdk/cosmos/azure-cosmos/test/test_partition_split_query.py
simorenoh Feb 7, 2024
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
Prev Previous commit
Next Next commit
Merged latest main and resolved conflicts
  • Loading branch information
kushagraThapar committed Jan 12, 2024
commit f7d9ca4570968a1fbc77f7d0a6ad4312205cdbf0
70 changes: 70 additions & 0 deletions sdk/cosmos/azure-cosmos/test/test_query_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,76 @@ async def test_continuation_token_size_limit_query_async(self):
assert len(token.encode('utf-8')) <= 1024
await self.created_db.delete_container(container)

async def test_computed_properties_query(self):
computed_properties = [{'name': "cp_lower", 'query': "SELECT VALUE LOWER(c.db_group) FROM c"},
{'name': "cp_power",
'query': "SELECT VALUE POWER(c.val, 2) FROM c"},
{'name': "cp_str_len", 'query': "SELECT VALUE LENGTH(c.stringProperty) FROM c"}]
items = [
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'prefixOne', 'db_group': 'GroUp1'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'prefixTwo', 'db_group': 'GrOUp1'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'randomWord1', 'db_group': 'GroUp2'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'randomWord2', 'db_group': 'groUp1'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'randomWord3', 'db_group': 'GroUp3'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'randomWord4', 'db_group': 'GrOUP1'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 5, 'stringProperty': 'randomWord5', 'db_group': 'GroUp2'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 0, 'stringProperty': 'randomWord6', 'db_group': 'group1'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 3, 'stringProperty': 'randomWord7', 'db_group': 'group2'},
{'id': str(uuid.uuid4()), 'pk': 'test', 'val': 2, 'stringProperty': 'randomWord8', 'db_group': 'GroUp3'}
]
created_database = await self.config.create_database_if_not_exist(self.client)
created_collection = await self.created_db.create_container_if_not_exists(
"computed_properties_query_test_" + str(uuid.uuid4()), PartitionKey(path="/pk")
, computed_properties=computed_properties)

# Create Items
for item in items:
await created_collection.create_item(body=item)

# Check if computed properties were set
container_properties = await created_collection._get_properties()
assert computed_properties == container_properties["computedProperties"]

# Test 0: Negative test, test if using non-existent computed property
queried_items = [q async for q in
created_collection.query_items(query='Select * from c Where c.cp_upper = "GROUP2"',
partition_key="test")]
assert len(queried_items) == 0

# Test 1: Test first computed property
queried_items = [q async for q in
created_collection.query_items(query='Select * from c Where c.cp_lower = "group1"',
partition_key="test")]
assert len(queried_items) == 5

# Test 1 Negative: Test if using non-existent string in group property returns nothing
queried_items = [q async for q in
created_collection.query_items(query='Select * from c Where c.cp_lower = "group4"',
partition_key="test")]
assert len(queried_items) == 0

# Test 2: Test second computed property
queried_items = [q async for q in created_collection.query_items(query='Select * from c Where c.cp_power = 25',
partition_key="test")]
assert len(queried_items) == 7

# Test 2 Negative: Test Non-Existent POWER
queried_items = [q async for q in created_collection.query_items(query='Select * from c Where c.cp_power = 16',
partition_key="test")]
assert len(queried_items) == 0

# Test 3: Test Third Computed Property
queried_items = [q async for q in created_collection.query_items(query='Select * from c Where c.cp_str_len = 9',
partition_key="test")]
assert len(queried_items) == 2

# Test 3 Negative: Test Str length that isn't there
queried_items = [q async for q in created_collection.query_items(query='Select * from c Where c.cp_str_len = 3',
partition_key="test")]
assert len(queried_items) == 0

await self.client.delete_database(created_database)


if __name__ == '__main__':
unittest.main()
You are viewing a condensed version of this merge commit. You can view the full changes here.