Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b46b72d
Update test_auto_scale_async.py
simorenoh Sep 13, 2023
2f7de81
parity
simorenoh Sep 13, 2023
9195608
update the way we use setup
simorenoh Sep 13, 2023
c1524d6
add the pytest mark for asyncio
simorenoh Sep 13, 2023
49602ac
remove connection policy
simorenoh Sep 13, 2023
1860a23
include aiohttp in dev_requirements for pipelines
simorenoh Sep 14, 2023
bbc63af
Update test_auto_scale_async.py
simorenoh Sep 14, 2023
cac28bf
facepalm moment
simorenoh Sep 14, 2023
c4366c7
replace database test
simorenoh Sep 14, 2023
651bb03
Update test_auto_scale.py
simorenoh Sep 14, 2023
22442f6
other async tests
simorenoh Sep 15, 2023
be71aec
fixes
simorenoh Sep 15, 2023
2314fef
small changes
simorenoh Sep 15, 2023
81b549c
more small fixes
simorenoh Sep 15, 2023
50a2753
more fixes
simorenoh Sep 15, 2023
62a28fa
changes
simorenoh Sep 15, 2023
153f9aa
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
7459fb1
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
0cc826e
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
fc74e36
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
6a7864e
Update sdk/cosmos/azure-cosmos/test/test_query_async.py
simorenoh Sep 15, 2023
b3a29b5
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
52abf37
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
edd5f1e
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
98f45da
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
c79dc70
Update sdk/cosmos/azure-cosmos/test/test_resource_id_async.py
simorenoh Sep 15, 2023
ec8dda1
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
24177b8
Update sdk/cosmos/azure-cosmos/test/test_query_async.py
simorenoh Sep 15, 2023
7685055
Update sdk/cosmos/azure-cosmos/test/test_query_async.py
simorenoh Sep 15, 2023
4abcfe3
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
144d5c3
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
d849fe4
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
519145b
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
d457f7d
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
19683af
Update sdk/cosmos/azure-cosmos/test/test_crud_async.py
simorenoh Sep 15, 2023
044787a
Update test_crud_async.py
simorenoh Sep 19, 2023
327c0bf
Update test_crud_async.py
simorenoh Sep 19, 2023
6aafb5f
tests changes
simorenoh Sep 19, 2023
6aaa878
Update test_crud_async.py
simorenoh Sep 19, 2023
19b9288
more test changes
simorenoh Sep 19, 2023
f900659
Update test_crud_async.py
simorenoh Sep 19, 2023
136df86
Merge branch 'main' into update-tests
simorenoh Sep 19, 2023
6bbca53
Update test_crud_async.py
simorenoh Sep 20, 2023
afe7bbf
Update test_query_async.py
simorenoh Sep 20, 2023
aee3750
Update test_query_async.py
simorenoh Sep 22, 2023
918becd
Update test_query_async.py
simorenoh Sep 22, 2023
f2d43c4
etag vs Etag difference in test - does this depend on OS?
simorenoh Sep 25, 2023
6668b7e
fixing wrong logic check
simorenoh Sep 25, 2023
e49ab68
Ubuntu2004_pypy39 returns etag as opposed to Etag
simorenoh Sep 26, 2023
7c4e8b4
more parenthesis
simorenoh Sep 26, 2023
d55b98c
Update test_query_async.py
simorenoh Sep 26, 2023
25f57b9
Update test_query_async.py
simorenoh Sep 26, 2023
4afa226
fixing tests dealing with weird/mock functionalities
simorenoh Sep 27, 2023
4c53f53
Update test_query_async.py
simorenoh Sep 27, 2023
bc91ffc
Update test_query_async.py
simorenoh Sep 28, 2023
c105c85
Update test_query_async.py
simorenoh Sep 29, 2023
7bfc165
Update test_query_async.py
simorenoh Sep 29, 2023
6fcd120
last small changes
simorenoh Oct 10, 2023
4d226aa
Update test_resource_id.py
simorenoh Oct 12, 2023
250da82
Update CHANGELOG.md
simorenoh Oct 17, 2023
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
tests changes
  • Loading branch information
simorenoh committed Sep 19, 2023
commit 6aafb5fd4ea7ef5c1e2203eb20eebb2866d32ec9
51 changes: 27 additions & 24 deletions sdk/cosmos/azure-cosmos/test/test_crud_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import pytest
from azure.core import MatchConditions
from azure.core.exceptions import AzureError, ServiceResponseError
from azure.core.pipeline.transport import RequestsTransport, RequestsTransportResponse
from azure.core.pipeline.transport import AsyncioRequestsTransport, AsyncioRequestsTransportResponse
import azure.cosmos.documents as documents
import azure.cosmos.exceptions as exceptions
from azure.cosmos.http_constants import HttpHeaders, StatusCodes
Expand All @@ -55,7 +55,7 @@
# associated with your Azure Cosmos account.


class TimeoutTransport(RequestsTransport):
class TimeoutTransport(AsyncioRequestsTransport):

def __init__(self, response):
self._response = response
Expand All @@ -70,7 +70,7 @@ async def send(self, *args, **kwargs):
raise self._response
output = requests.Response()
output.status_code = self._response
response = RequestsTransportResponse(None, output)
response = AsyncioRequestsTransportResponse(None, output)
return response


Expand Down Expand Up @@ -697,7 +697,8 @@ async def test_partitioned_collection_partition_key_value_types_async(self):
async def test_partitioned_collection_conflict_crud_and_query_async(self):
await self._set_up()

created_collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()), PartitionKey(path="/id"))
created_collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()),
PartitionKey(path="/id"))

conflict_definition = {'id': 'new conflict',
'resourceId': 'doc1',
Expand Down Expand Up @@ -785,7 +786,7 @@ async def test_document_crud_async(self):
assert document_list is not None
document_list = [document async for document in created_collection.query_items(
query='SELECT * FROM root r WHERE r.name=@name',
parameter=[
parameters=[
{'name': '@name', 'value': document_definition['name']}
],
enable_scan_in_query=True
Expand Down Expand Up @@ -889,7 +890,8 @@ async def test_document_upsert_async(self):
await self._set_up()

# create collection
created_collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()), PartitionKey(path="/id"))
created_collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()),
PartitionKey(path="/id"))

# read documents and check count
document_list = [document async for document in created_collection.read_all_items()]
Expand Down Expand Up @@ -1301,7 +1303,7 @@ async def __setup_entities():
async with CosmosClient(TestCRUDAsync.host, {}) as client:
[db async for db in client.list_databases()]
except exceptions.CosmosHttpResponseError as e:
assert e.status_code == StatusCodes.UNAUTHORIZED
assert e.status_code == StatusCodes.UNAUTHORIZED

# Client with master key.
async with CosmosClient(TestCRUDAsync.host,
Expand Down Expand Up @@ -1367,7 +1369,8 @@ async def __setup_entities():
async def test_trigger_crud_async(self):
await self._set_up()
# create collection
collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()), PartitionKey(path="/id"))
collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()),
PartitionKey(path="/id"))
# read triggers
triggers = [trigger async for trigger in collection.scripts.list_triggers()]
# create a trigger
Expand Down Expand Up @@ -1422,7 +1425,8 @@ async def test_trigger_crud_async(self):
async def test_udf_crud_async(self):
await self._set_up()
# create collection
collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()), PartitionKey(path="/id"))
collection = await self.database_for_test.create_container_if_not_exists(str(uuid.uuid4()),
PartitionKey(path="/id"))
# read udfs
udfs = [udf async for udf in collection.scripts.list_user_defined_functions()]
# create a udf
Expand Down Expand Up @@ -1821,17 +1825,12 @@ async def test_client_request_timeout_when_connection_retry_configuration_specif
connection_policy = documents.ConnectionPolicy()
# making timeout 0 ms to make sure it will throw
connection_policy.RequestTimeout = 0.000000000001
connection_policy.ConnectionRetryConfiguration = Retry(
total=3,
read=3,
connect=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504)
)
with pytest.raises(AzureError):
# client does a getDatabaseAccount on initialization, which will time out
async with CosmosClient(TestCRUDAsync.host, TestCRUDAsync.masterKey,
connection_policy=connection_policy) as client:
connection_policy=connection_policy,
retry_total=3, retry_connect=3, retry_read=3, retry_backoff_max=0.3,
retry_on_status_codes=[500, 502, 504]) as client:
print('Async Initialization')

@pytest.mark.asyncio
Expand Down Expand Up @@ -1930,6 +1929,7 @@ async def test_absolute_client_timeout_async(self):
@pytest.mark.asyncio
async def test_query_iterable_functionality_async(self):
await self._set_up()

async def __create_resources():
"""Creates resources for this test.

Expand All @@ -1943,9 +1943,9 @@ async def __create_resources():
collection = await self.database_for_test.create_container(
test_config._test_config.TEST_COLLECTION_MULTI_PARTITION_WITH_CUSTOM_PK_PARTITION_KEY,
PartitionKey(path="/pk"))
doc1 = await collection.create_item(body={'id': 'doc1', 'prop1': 'value1'})
doc2 = await collection.create_item(body={'id': 'doc2', 'prop1': 'value2'})
doc3 = await collection.create_item(body={'id': 'doc3', 'prop1': 'value3'})
doc1 = await collection.upsert_item(body={'id': 'doc1', 'prop1': 'value1'})
doc2 = await collection.upsert_item(body={'id': 'doc2', 'prop1': 'value2'})
doc3 = await collection.upsert_item(body={'id': 'doc3', 'prop1': 'value3'})
resources = {
'coll': collection,
'doc1': doc1,
Expand Down Expand Up @@ -2184,7 +2184,7 @@ async def test_stored_procedure_functionality_async(self):
retrieved_sproc3 = await collection.scripts.create_stored_procedure(body=sproc3)
result = await collection.scripts.execute_stored_procedure(
sproc=retrieved_sproc3['id'],
params=[{'temp': 'so'}],
parameters={'temp': 'so'},
partition_key=1
)
assert result == 'aso'
Expand Down Expand Up @@ -2239,7 +2239,8 @@ async def test_offer_replace_async(self):
collection_properties = await collection.read()
self.__validate_offer_response_body(replaced_offer, collection_properties.get('_self'), None)
# Check if the replaced offer is what we expect.
assert expected_offer.properties.get('content').get('offerThroughput') + 100 == replaced_offer.properties.get('content').get('offerThroughput')
assert expected_offer.properties.get('content').get('offerThroughput') + 100 == replaced_offer.properties.get(
'content').get('offerThroughput')
assert expected_offer.offer_throughput + 100 == replaced_offer.offer_throughput
await self._clear()

Expand All @@ -2252,10 +2253,12 @@ async def test_database_account_functionality_async(self):
assert database_account.MediaLink == '/media/'
if (HttpHeaders.MaxMediaStorageUsageInMB in
self.client.client_connection.last_response_headers):
assert database_account.MaxMediaStorageUsageInMB == self.client.client_connection.last_response_headers[HttpHeaders.MaxMediaStorageUsageInMB]
assert database_account.MaxMediaStorageUsageInMB == self.client.client_connection.last_response_headers[
HttpHeaders.MaxMediaStorageUsageInMB]
if (HttpHeaders.CurrentMediaStorageUsageInMB in
self.client.client_connection.last_response_headers):
assert database_account.CurrentMediaStorageUsageInMB == self.client.client_connection.last_response_headers[HttpHeaders.CurrentMediaStorageUsageInMB]
assert database_account.CurrentMediaStorageUsageInMB == self.client.client_connection.last_response_headers[
HttpHeaders.CurrentMediaStorageUsageInMB]
assert database_account.ConsistencyPolicy['defaultConsistencyLevel'] is not None
await self._clear()

Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure-cosmos/test/test_query_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ async def test_paging_with_continuation_token_async(self):
self.config.TEST_COLLECTION_MULTI_PARTITION_WITH_CUSTOM_PK_ID, PartitionKey(path="/pk"))

document_definition = {'pk': 'pk', 'id': '1'}
await created_collection.create_item(body=document_definition)
await created_collection.upsert_item(body=document_definition)
document_definition = {'pk': 'pk', 'id': '2'}
await created_collection.create_item(body=document_definition)
await created_collection.upsert_item(body=document_definition)

query = 'SELECT * from c'
query_iterable = created_collection.query_items(
Expand Down
12 changes: 6 additions & 6 deletions sdk/cosmos/azure-cosmos/test/test_resource_id_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def test_create_illegal_characters_async(self):

# Define errors returned by checks
illegal_chars_string = 'Id contains illegal chars.'
space_chars_string = 'Id ends with a space.'
# space_chars_string = 'Id ends with a space.'

# Define illegal strings
illegal_strings = [
Expand All @@ -109,15 +109,15 @@ async def test_create_illegal_characters_async(self):

# test illegal resource id's for all resources
for resource_id in illegal_strings:
if resource_id == "ID_with_trailing_spaces ":
error_string = space_chars_string
else:
error_string = illegal_chars_string
# if resource_id == "ID_with_trailing_spaces ":
# error_string = space_chars_string
# else:
# error_string = illegal_chars_string
try:
await self.client.create_database(resource_id)
pytest.fail("Database create should have failed for id {}".format(resource_id))
except ValueError as e:
assert str(e) == error_string
assert str(e) == illegal_chars_string

try:
await created_database.create_container(id=resource_id, partition_key=partition_key)
Expand Down