Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase


class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):
def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()

Expand Down
4 changes: 2 additions & 2 deletions sdk/compute/azure-mgmt-compute/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()
Expand Down
14 changes: 0 additions & 14 deletions sdk/devcenter/azure-developer-devcenter/tests/testcase_async.py

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/easm/azure-defender-easm/tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# license information.
# --------------------------------------------------------------------------
import functools
from devtools_testutils import AzureTestCase, AzureRecordedTestCase, EnvironmentVariableLoader
from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader
from azure.defender.easm import EasmClient
import datetime

Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/azure-mgmt-eventhub/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

import azure.mgmt.hanaonazure.models

from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer
from devtools_testutils import AzureMgmtRecordedTestCase, ResourceGroupPreparer

class MgmtHanaOnAzureTest(AzureMgmtTestCase):
class TestMgmtHanaOnAzure(AzureMgmtRecordedTestCase):

def setUp(self):
super(MgmtHanaOnAzureTest, self).setUp()
super(TestMgmtHanaOnAzure, self).setUp()

self.hanaonazure_client = self.create_mgmt_client(
azure.mgmt.hanaonazure.HanaManagementClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from azure.mgmt.managementpartner import ACEProvisioningManagementPartnerAPI
from azure.mgmt.managementpartner.models import PartnerResponse
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase
import unittest


@unittest.skip("hard to test")
class MgmtPartnerTest(AzureMgmtTestCase):
class TestMgmtPartner(AzureMgmtRecordedTestCase):

def _validate_partner(self, PartnerResponse):
self.assertIsNotNone(PartnerResponse)
Expand All @@ -20,7 +20,7 @@ def _validate_partner(self, PartnerResponse):
self.assertIsNotNone(PartnerResponse.version)

def setUp(self):
super(MgmtPartnerTest, self).setUp()
super(TestMgmtPartner, self).setUp()
self.managementpartner_client = self.create_basic_client(ACEProvisioningManagementPartnerAPI)

def test_managementpartner_get(self):
Expand Down
29 changes: 13 additions & 16 deletions sdk/maps/azure-maps-search/tests/test_client_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
import pytest
import unittest
from unittest.mock import Mock
from devtools_testutils import AzureTestCase
from azure.core.credentials import AzureKeyCredential
from azure.maps.search.models import StructuredAddress
from azure.maps.search import MapsSearchClient
from azure.maps.search._shared import converter

# cSpell:disable
class AzureMapsSearchClientUnitTest(AzureTestCase):

def test_fuzzy_search_invalid_top(self):
client = MapsSearchClient(
credential=Mock(AzureKeyCredential)
)
with pytest.raises(TypeError):
client.search_point_of_interest_category(StructuredAddress())

def test_search_structured_address(self):
client = MapsSearchClient(
credential=Mock(AzureKeyCredential)
)
with pytest.raises(TypeError):
client.search_structured_address(StructuredAddress())
def test_fuzzy_search_invalid_top():
client = MapsSearchClient(
credential=Mock(AzureKeyCredential)
)
with pytest.raises(TypeError):
client.search_point_of_interest_category(StructuredAddress())

def test_search_structured_address():
client = MapsSearchClient(
credential=Mock(AzureKeyCredential)
)
with pytest.raises(TypeError):
client.search_structured_address(StructuredAddress())

class TestConverter(unittest.TestCase):

Expand Down
4 changes: 2 additions & 2 deletions sdk/media/azure-mgmt-media/tests/test_mgmt_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import azure.mgmt.storage

from devtools_testutils import (
AzureMgmtTestCase, ResourceGroupPreparer,
AzureMgmtRecordedTestCase, ResourceGroupPreparer,
StorageAccountPreparer, FakeStorageAccount,
)

Expand All @@ -28,7 +28,7 @@
)

raise unittest.SkipTest("Skipping all tests")
class MgmtMediaTest(AzureMgmtTestCase):
class TestMgmtMedia(AzureMgmtRecordedTestCase):

def setUp(self):
super(MgmtMediaTest, self).setUp()
Expand Down
4 changes: 2 additions & 2 deletions sdk/monitor/azure-mgmt-monitor/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest

from azure.mgmt.reservations import AzureReservationAPI
from azure.mgmt.reservations.models import *
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase
from azure.mgmt.reservations.models import (
ReservedResourceType,
InstanceFlexibility,
Expand All @@ -12,11 +14,10 @@
# change the custom endpoint to set the environment
_CUSTOM_ENDPOINT = "https://api-dogfood.resources.windows-int.net/"

@unittest.skip("skip test")
class MgmtReservationsTest(AzureMgmtTestCase):
@pytest.mark.skip("skip test")
class TestMgmtReservations(AzureMgmtRecordedTestCase):

def setUp(self):
super(MgmtReservationsTest, self).setUp()
def setup_method(self, _):
self.reservation_client = self.create_basic_client(AzureReservationAPI, base_url=_CUSTOM_ENDPOINT)
# self.reservation_client = self.create_basic_client(AzureReservationAPI)

Expand Down
4 changes: 2 additions & 2 deletions sdk/resources/azure-mgmt-resource/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
# applications: 10/10
# application_definitions: 7/7

import pytest
import unittest

import azure.mgmt.resource
# import azure.mgmt.managementgroups
import azure.mgmt.resource.resources.v2019_10_01
from azure.core.exceptions import HttpResponseError
from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer
from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer

@unittest.skip("Hard to test, skip them")
class MgmtResourceLinksTest(AzureMgmtTestCase):
@pytest.mark.skip("Hard to test, skip them")
class TestMgmtResourceLinks(AzureMgmtRecordedTestCase):

def setUp(self):
super(MgmtResourceLinksTest, self).setUp()
super(TestMgmtResourceLinks, self).setUp()
self.mgmt_client = self.create_mgmt_client(
azure.mgmt.resource.ApplicationClient
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
import pytest
import unittest

from azure.mgmt.resourcegraph import ResourceGraphClient
from azure.mgmt.resourcegraph.models import *
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

@unittest.skip("The test doesn't work.")
class MgmtResourceGraphTest(AzureMgmtTestCase):
@pytest.mark.skip("The test doesn't work.")
class TestMgmtResourceGraph(AzureMgmtRecordedTestCase):

def setUp(self):
super(MgmtResourceGraphTest, self).setUp()
super(TestMgmtResourceGraph, self).setUp()
self.resourcegraph_client = self.create_basic_client(
ResourceGraphClient
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
from azure.schemaregistry import SchemaRegistryClient
from azure.schemaregistry.encoder.avroencoder import AvroEncoder
from azure.schemaregistry.encoder.avroencoder import InvalidContentError, InvalidSchemaError
from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy, AzureTestCase
from devtools_testutils import AzureRecordedTestCase, EnvironmentVariableLoader, recorded_by_proxy

import avro
from avro.errors import AvroTypeException
from azure.schemaregistry.encoder.avroencoder._apache_avro_encoder import ApacheAvroObjectEncoder as AvroObjectEncoder

from devtools_testutils import AzureTestCase

SchemaRegistryEnvironmentVariableLoader = functools.partial(
EnvironmentVariableLoader,
"schemaregistry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
from azure.identity import ClientSecretCredential
from azure.core.exceptions import ClientAuthenticationError, ServiceRequestError, HttpResponseError

from devtools_testutils import AzureTestCase, PowerShellPreparer
from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer

SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_fully_qualified_namespace="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup")

class AvroSerializerTests(AzureTestCase):
class TestAvroSerializer(AzureRecordedTestCase):

def test_raw_avro_serializer(self):
schema_str = """{"namespace":"example.avro","type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"favorite_number","type":["int","null"]},{"name":"favorite_color","type":["string","null"]}]}"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
from azure.identity.aio import ClientSecretCredential
from azure.core.exceptions import ClientAuthenticationError, ServiceRequestError, HttpResponseError

from devtools_testutils import AzureTestCase, PowerShellPreparer
from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer

SchemaRegistryPowerShellPreparer = functools.partial(PowerShellPreparer, "schemaregistry", schemaregistry_fully_qualified_namespace="fake_resource.servicebus.windows.net/", schemaregistry_group="fakegroup")

class AvroSerializerAsyncTests(AzureTestCase):
class TestAvroSerializerAsync(AzureRecordedTestCase):

def create_client(self, fully_qualified_namespace):
credential = self.get_credential(SchemaRegistryClient, is_async=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
MessageSizeExceededError,
OperationTimeoutError
)
from devtools_testutils import AzureMgmtRecordedTestCase, AzureTestCase
from devtools_testutils import AzureMgmtRecordedTestCase, AzureRecordedTestCase
from servicebus_preparer import (
CachedServiceBusNamespacePreparer,
CachedServiceBusQueuePreparer,
Expand Down Expand Up @@ -1756,7 +1756,7 @@ async def test_queue_message_settle_through_mgmt_link_due_to_broken_receiver_lin
await receiver.complete_message(messages[0])

@pytest.mark.skip('hard to test')
@AzureTestCase.await_prepared_test
@AzureRecordedTestCase.await_prepared_test
async def test_async_queue_mock_auto_lock_renew_callback(self):
# A warning to future devs: If the renew period override heuristic in registration
# ever changes, it may break this (since it adjusts renew period if it is not short enough)
Expand Down Expand Up @@ -1839,7 +1839,7 @@ async def callback_mock(renewable, error):
assert not results
assert not errors

@AzureTestCase.await_prepared_test
@AzureRecordedTestCase.await_prepared_test
async def test_async_queue_mock_no_reusing_auto_lock_renew(self):
auto_lock_renew = AutoLockRenewer()
auto_lock_renew._renew_period = 1
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azure-mgmt-storage/tests/_aio_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from unittest.mock import Mock

from azure.core.credentials import AccessToken
from devtools_testutils import AzureMgmtTestCase
from devtools_testutils import AzureMgmtRecordedTestCase

class AzureMgmtAsyncTestCase(AzureMgmtTestCase):
class AzureMgmtAsyncTestCase(AzureMgmtRecordedTestCase):

def setUp(self):
super(AzureMgmtAsyncTestCase, self).setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
# license information.
# --------------------------------------------------------------------------
import functools
from devtools_testutils import AzureTestCase, PowerShellPreparer
from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer
from azure.messaging.webpubsubservice import WebPubSubServiceClient


class WebpubsubTest(AzureTestCase):
def __init__(self, method_name, **kwargs):
super(WebpubsubTest, self).__init__(method_name, **kwargs)

class WebpubsubTest(AzureRecordedTestCase):
def create_client(self, endpoint=None, hub=None, reverse_proxy_endpoint=None, **kwargs):
if kwargs.get("connection_string"):
return WebPubSubServiceClient.from_connection_string(kwargs.pop("connection_string"), hub, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from devtools_testutils import AzureTestCase
from devtools_testutils import AzureRecordedTestCase
from azure.messaging.webpubsubservice.aio import WebPubSubServiceClient


class WebpubsubAsyncTest(AzureTestCase):
def __init__(self, method_name, **kwargs):
super(WebpubsubAsyncTest, self).__init__(method_name, **kwargs)

class WebpubsubAsyncTest(AzureRecordedTestCase):
def create_client(self, endpoint=None, hub=None, reverse_proxy_endpoint=None, **kwargs):
if kwargs.get("connection_string"):
return WebPubSubServiceClient.from_connection_string(kwargs.pop("connection_string"), hub, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion tools/azure-sdk-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This package is intended for usage in direct combination with the azure-sdk-for-python repo. It provides:

- Common test classes and functionality
- `AzureTestCase` used for common record/playback functionality
- `AzureRecordedTestCase` used for common record/playback functionality
- `EnvironmentVariablePreparer` to allow recorded tests access to `New-TestResources.ps1`-created resources.
- Test-Proxy Shim/Startup capabilities
- `Build` entrypoint
Expand Down
Loading