Skip to content

Commit 7ba8f7c

Browse files
authored
[SchemaRegistry] remove pinned azure-schemaregistry in dev reqs (#37631)
* fix verifytypes * recordings update * scrub api-version * remove accept header from recordings * remove type error message check b/c different messages
1 parent e7724da commit 7ba8f7c

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

sdk/eventhub/azure-eventhub/samples/async_samples/send_and_receive_amqp_annotated_message_async.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
import os
1313
import asyncio
14+
from azure.eventhub import TransportType
1415
from azure.eventhub.aio import EventHubProducerClient, EventHubConsumerClient
1516
from azure.eventhub.amqp import AmqpAnnotatedMessage, AmqpMessageBodyType
16-
from azure.identity.aio import DefaultAzureCredential
17+
from azure.identity.aio import AzureCliCredential
1718

1819
FULLY_QUALIFIED_NAMESPACE = os.environ["EVENT_HUB_HOSTNAME"]
1920
EVENTHUB_NAME = os.environ['EVENT_HUB_NAME']
@@ -97,7 +98,8 @@ async def main():
9798
producer = EventHubProducerClient(
9899
fully_qualified_namespace=FULLY_QUALIFIED_NAMESPACE,
99100
eventhub_name=EVENTHUB_NAME,
100-
credential=DefaultAzureCredential(),
101+
credential=AzureCliCredential(),
102+
transport_type=TransportType.AmqpOverWebsocket
101103
)
102104
async with producer:
103105
await send_data_message(producer)
@@ -107,9 +109,10 @@ async def main():
107109
# Receive
108110
consumer = EventHubConsumerClient(
109111
fully_qualified_namespace=FULLY_QUALIFIED_NAMESPACE,
110-
credential=DefaultAzureCredential(),
112+
credential=AzureCliCredential(),
111113
consumer_group='$Default',
112114
eventhub_name=EVENTHUB_NAME,
115+
transport_type=TransportType.AmqpOverWebsocket
113116
)
114117
await receive_and_parse_message(consumer)
115118

sdk/schemaregistry/azure-schemaregistry-avroencoder/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/schemaregistry/azure-schemaregistry-avroencoder",
5-
"Tag": "python/schemaregistry/azure-schemaregistry-avroencoder_50158ba496"
5+
"Tag": "python/schemaregistry/azure-schemaregistry-avroencoder_0971c24bdc"
66
}

sdk/schemaregistry/azure-schemaregistry-avroencoder/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
from devtools_testutils import (
33
test_proxy,
44
add_general_regex_sanitizer,
5+
add_remove_header_sanitizer,
56
add_oauth_response_sanitizer,
67
remove_batch_sanitizers,
78
)
89

910
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
1011
@pytest.fixture(scope="session", autouse=True)
1112
def add_sanitizers(test_proxy):
13+
# Scrubbing api-version since latest and mindependency versions of azure-schemaregistry will not be the same.
14+
add_general_regex_sanitizer(regex="(?<=api-version=)[0-9]{4}-[0-9]{2}", value="xxxx-xx")
1215
add_general_regex_sanitizer(regex="(?<=\\/\\/)[a-z-]+(?=\\.servicebus\\.windows\\.net)", value="fake_resource_avro")
16+
# Accept is not used by the service. Removing from request headers so changes to Accept are not flagged as diffs.
17+
add_remove_header_sanitizer(headers="Accept")
1318
add_oauth_response_sanitizer()
1419

1520
# Remove the following sanitizers since certain fields are needed in tests and are non-sensitive:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-e ../../../tools/azure-sdk-tools
22
-e ../../identity/azure-identity
33
aiohttp>=3.0
4-
azure-schemaregistry<=1.2.0
4+
azure-schemaregistry

sdk/schemaregistry/azure-schemaregistry-avroencoder/tests/test_avro_encoder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,16 @@ def test_basic_sr_avro_encoder_with_request_options(self, **kwargs):
275275
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"]}]}"""
276276

277277
dict_content = {"name": u"Ben", "favorite_number": 7, "favorite_color": u"red"}
278+
# if fake kwargs/incorrectly formatted request keyword passed in, should raise TypeError
278279
with pytest.raises(TypeError) as e:
279-
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str, request_options={"fake_kwarg": True})
280-
assert 'request() got an unexpected keyword' in str(e.value)
280+
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str, request_options={"fake_kwarg": True, "files": frozenset({'a': False})})
281281
encoded_message_content = sr_avro_encoder.encode(dict_content, schema=schema_str)
282282
content_type = encoded_message_content["content_type"]
283283
encoded_content = encoded_message_content["content"]
284284

285285
encoded_content_dict = {"content": encoded_content, "content_type": content_type}
286286
with pytest.raises(TypeError) as e:
287-
decoded_content = sr_avro_encoder.decode(encoded_content_dict, request_options={"fake_kwarg": True})
288-
assert 'request() got an unexpected keyword' in str(e.value)
287+
decoded_content = sr_avro_encoder.decode(encoded_content_dict, request_options={"fake_kwarg": True, "files": (False)})
289288

290289

291290
#################################################################

sdk/schemaregistry/azure-schemaregistry-avroencoder/tests/test_avro_encoder_async.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,16 @@ async def test_basic_sr_avro_encoder_with_request_options(self, **kwargs):
240240
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"]}]}"""
241241

242242
dict_content = {"name": u"Ben", "favorite_number": 7, "favorite_color": u"red"}
243+
# if fake kwargs/incorrectly formatted request keyword passed in, should raise TypeError
243244
with pytest.raises(TypeError) as e:
244-
encoded_message_content = await sr_avro_encoder.encode(dict_content, schema=schema_str, request_options={"fake_kwarg": True})
245-
assert 'request() got an unexpected keyword' in str(e.value)
245+
encoded_message_content = await sr_avro_encoder.encode(dict_content, schema=schema_str, request_options={"fake_kwarg": True, "files": (False)})
246246
encoded_message_content = await sr_avro_encoder.encode(dict_content, schema=schema_str)
247247
content_type = encoded_message_content["content_type"]
248248
encoded_content = encoded_message_content["content"]
249249

250250
encoded_content_dict = {"content": encoded_content, "content_type": content_type}
251251
with pytest.raises(TypeError) as e:
252-
decoded_content = await sr_avro_encoder.decode(encoded_content_dict, request_options={"fake_kwarg": True})
253-
assert 'request() got an unexpected keyword' in str(e.value)
252+
decoded_content = await sr_avro_encoder.decode(encoded_content_dict, request_options={"fake_kwarg": True, "files": (False)})
254253

255254
#################################################################
256255
######################### PARSE SCHEMAS #########################

0 commit comments

Comments
 (0)