Skip to content

Commit

Permalink
remove EGPubClient
Browse files Browse the repository at this point in the history
  • Loading branch information
l0lawrence committed Apr 4, 2024
1 parent 475ed6a commit bf94364
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 44 deletions.
9 changes: 5 additions & 4 deletions sdk/eventgrid/azure-eventgrid/tests/perfstress_tests/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from devtools_testutils.perfstress_tests import PerfStressTest

from azure.eventgrid import (
EventGridPublisherClient as SyncPublisherClient,
EventGridClient as SyncPublisherClient,
EventGridEvent,
ClientLevel
)
from azure.eventgrid.aio import EventGridPublisherClient as AsyncPublisherClient
from azure.eventgrid.aio import EventGridClient as AsyncPublisherClient

from azure.core.credentials import AzureKeyCredential

Expand All @@ -26,10 +27,10 @@ def __init__(self, arguments):

# Create clients
self.publisher_client = SyncPublisherClient(
endpoint=endpoint, credential=AzureKeyCredential(topic_key)
endpoint=endpoint, credential=AzureKeyCredential(topic_key), level=ClientLevel.BASIC
)
self.async_publisher_client = AsyncPublisherClient(
endpoint=endpoint, credential=AzureKeyCredential(topic_key)
endpoint=endpoint, credential=AzureKeyCredential(topic_key), level=ClientLevel.BASIC
)

self.event_list = []
Expand Down
6 changes: 3 additions & 3 deletions sdk/eventgrid/azure-eventgrid/tests/test_cncf_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy

from azure.core.credentials import AzureKeyCredential, AzureSasCredential
from azure.eventgrid import EventGridPublisherClient
from azure.eventgrid import EventGridClient, ClientLevel
from cloudevents.http import CloudEvent

from eventgrid_preparer import (
Expand All @@ -12,9 +12,9 @@

class TestEventGridPublisherClientCncf(AzureRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient)
credential = self.get_credential(EventGridClient)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

Expand Down
9 changes: 5 additions & 4 deletions sdk/eventgrid/azure-eventgrid/tests/test_cncf_events_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
from devtools_testutils.aio import recorded_by_proxy_async

from azure.core.credentials import AzureKeyCredential, AzureSasCredential
from azure.eventgrid.aio import EventGridPublisherClient
from azure.eventgrid.aio import EventGridClient
from azure.eventgrid import ClientLevel
from cloudevents.http import CloudEvent

from eventgrid_preparer import (
EventGridPreparer,
)


class TestEventGridPublisherClientCncf(AzureRecordedTestCase):
class TestEventGridClientCncf(AzureRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient, is_async=True)
credential = self.get_credential(EventGridClient, is_async=True)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

Expand Down
22 changes: 11 additions & 11 deletions sdk/eventgrid/azure-eventgrid/tests/test_eg_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from azure.core.credentials import AzureKeyCredential, AzureSasCredential
from azure.core.messaging import CloudEvent
from azure.core.serialization import NULL
from azure.eventgrid import EventGridPublisherClient, EventGridEvent, generate_sas
from azure.eventgrid import EventGridClient, EventGridEvent, generate_sas, ClientLevel
from azure.eventgrid._legacy._helpers import _cloud_event_to_generated

from eventgrid_preparer import (
Expand All @@ -34,9 +34,9 @@

class TestEventGridPublisherClient(AzureRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient)
credential = self.get_credential(EventGridClient)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

Expand All @@ -59,7 +59,7 @@ def test_send_event_grid_event_fails_without_full_url(
):
akc_credential = AzureKeyCredential(eventgrid_topic_key)
parsed_url = urlparse(eventgrid_topic_endpoint)
client = EventGridPublisherClient(parsed_url.netloc, akc_credential)
client = EventGridClient(parsed_url.netloc, akc_credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand Down Expand Up @@ -298,7 +298,7 @@ def test_send_signature_credential(self, eventgrid_topic_key, eventgrid_topic_en
eventgrid_topic_endpoint, eventgrid_topic_key, expiration_date_utc
)
credential = AzureSasCredential(signature)
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
client = EventGridClient(eventgrid_topic_endpoint, credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand All @@ -313,7 +313,7 @@ def test_send_NONE_credential(self, eventgrid_topic_endpoint):
with pytest.raises(
ValueError, match="Parameter 'self._credential' must not be None."
):
client = EventGridPublisherClient(eventgrid_topic_endpoint, None)
client = EventGridClient(eventgrid_topic_endpoint, None, level=ClientLevel.BASIC)

@EventGridPreparer()
@recorded_by_proxy
Expand Down Expand Up @@ -361,14 +361,14 @@ def test_send_throws_with_bad_credential(self):
ValueError,
match="The provided credential should be an instance of a TokenCredential, AzureSasCredential or AzureKeyCredential",
):
client = EventGridPublisherClient("eventgrid_endpoint", bad_credential)
client = EventGridClient("eventgrid_endpoint", bad_credential, level=ClientLevel.BASIC)

@pytest.mark.live_test_only
@EventGridPreparer()
@recorded_by_proxy
def test_send_token_credential(self, eventgrid_topic_endpoint):
credential = self.get_credential(EventGridPublisherClient)
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
credential = self.get_credential(EventGridClient)
client = EventGridClient(eventgrid_topic_endpoint, credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand All @@ -382,8 +382,8 @@ def test_send_token_credential(self, eventgrid_topic_endpoint):
@recorded_by_proxy
def test_send_partner_namespace(self, eventgrid_partner_namespace_topic_endpoint, eventgrid_partner_namespace_topic_key, eventgrid_partner_channel_name):
credential = AzureKeyCredential(eventgrid_partner_namespace_topic_key)
client = EventGridPublisherClient(
eventgrid_partner_namespace_topic_endpoint, credential
client = EventGridClient(
eventgrid_partner_namespace_topic_endpoint, credential, level=ClientLevel.BASIC
)
cloud_event = CloudEvent(
source="http://samplesource.dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
from azure.core.credentials import AzureKeyCredential, AzureSasCredential
from azure.core.messaging import CloudEvent
from azure.core.serialization import NULL
from azure.eventgrid import EventGridEvent, generate_sas
from azure.eventgrid.aio import EventGridPublisherClient
from azure.eventgrid import EventGridEvent, generate_sas, ClientLevel
from azure.eventgrid.aio import EventGridClient
from azure.eventgrid._legacy._helpers import _cloud_event_to_generated

from eventgrid_preparer import EventGridPreparer


class TestEventGridPublisherClient(AzureRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient, is_async=True)
credential = self.get_credential(EventGridClient, is_async=True)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

Expand Down Expand Up @@ -80,7 +80,7 @@ async def test_send_event_grid_event_fails_without_full_url_async(
):
akc_credential = AzureKeyCredential(eventgrid_topic_key)
parsed_url = urlparse(eventgrid_topic_endpoint)
client = EventGridPublisherClient(parsed_url.netloc, akc_credential)
client = EventGridClient(parsed_url.netloc, akc_credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand Down Expand Up @@ -284,7 +284,7 @@ async def test_send_signature_credential_async(
eventgrid_topic_endpoint, eventgrid_topic_key, expiration_date_utc
)
credential = AzureSasCredential(signature)
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
client = EventGridClient(eventgrid_topic_endpoint, credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand Down Expand Up @@ -357,15 +357,15 @@ def test_send_NONE_credential_async(self, eventgrid_topic_endpoint):
with pytest.raises(
ValueError, match="Parameter 'self._credential' must not be None."
):
client = EventGridPublisherClient(eventgrid_topic_endpoint, None)
client = EventGridClient(eventgrid_topic_endpoint, None, level=ClientLevel.BASIC)

@pytest.mark.live_test_only
@EventGridPreparer()
@recorded_by_proxy_async
@pytest.mark.asyncio
async def test_send_token_credential_async(self, eventgrid_topic_endpoint):
credential = self.get_credential(EventGridPublisherClient)
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
credential = self.get_credential(EventGridClient)
client = EventGridClient(eventgrid_topic_endpoint, credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand All @@ -379,8 +379,8 @@ async def test_send_token_credential_async(self, eventgrid_topic_endpoint):
@recorded_by_proxy_async
async def test_send_partner_namespace_async(self, eventgrid_partner_namespace_topic_endpoint, eventgrid_partner_namespace_topic_key, eventgrid_partner_channel_name):
credential = AzureKeyCredential(eventgrid_partner_namespace_topic_key)
client = EventGridPublisherClient(
eventgrid_partner_namespace_topic_endpoint, credential
client = EventGridClient(
eventgrid_partner_namespace_topic_endpoint, credential, level=ClientLevel.BASIC
)
cloud_event = CloudEvent(
source="http://samplesource.dev",
Expand Down
11 changes: 6 additions & 5 deletions sdk/eventgrid/azure-eventgrid/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from devtools_testutils import AzureMgmtRecordedTestCase, recorded_by_proxy

from azure.core.credentials import AzureKeyCredential
from azure.eventgrid import EventGridPublisherClient, EventGridEvent
from azure.eventgrid import EventGridClient, EventGridEvent, ClientLevel
from azure.core.messaging import CloudEvent

from eventgrid_preparer import (
Expand All @@ -37,17 +37,17 @@

class TestEventGridPublisherClientExceptions(AzureMgmtRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient)
credential = self.get_credential(EventGridClient)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

@EventGridPreparer()
@recorded_by_proxy
def test_raise_on_auth_error(self, eventgrid_topic_endpoint):
akc_credential = AzureKeyCredential("bad credential")
client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential)
client = EventGridClient(eventgrid_topic_endpoint, akc_credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand All @@ -64,9 +64,10 @@ def test_raise_on_auth_error(self, eventgrid_topic_endpoint):
@pytest.mark.live_test_only
def test_raise_on_bad_resource(self):
credential = AzureKeyCredential(os.environ["EVENTGRID_TOPIC_KEY"])
client = EventGridPublisherClient(
client = EventGridClient(
"https://bad-resource.eastus-1.eventgrid.azure.net/api/events",
credential,
level=ClientLevel.BASIC,
)
eg_event = CloudEvent(
subject="sample",
Expand Down
13 changes: 7 additions & 6 deletions sdk/eventgrid/azure-eventgrid/tests/test_exceptions_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from azure.core.credentials import AzureKeyCredential, AzureSasCredential
from azure.core.messaging import CloudEvent
from azure.core.serialization import NULL
from azure.eventgrid import EventGridEvent, generate_sas
from azure.eventgrid.aio import EventGridPublisherClient
from azure.eventgrid import EventGridEvent, generate_sas, ClientLevel
from azure.eventgrid.aio import EventGridClient
from azure.eventgrid._legacy._helpers import _cloud_event_to_generated

from eventgrid_preparer import (
Expand All @@ -41,9 +41,9 @@

class TestEventGridPublisherClientExceptionsAsync(AzureRecordedTestCase):
def create_eg_publisher_client(self, endpoint):
credential = self.get_credential(EventGridPublisherClient, is_async=True)
credential = self.get_credential(EventGridClient, is_async=True)
client = self.create_client_from_credential(
EventGridPublisherClient, credential=credential, endpoint=endpoint
EventGridClient, credential=credential, endpoint=endpoint, level=ClientLevel.BASIC
)
return client

Expand All @@ -52,7 +52,7 @@ def create_eg_publisher_client(self, endpoint):
@pytest.mark.asyncio
async def test_raise_on_auth_error(self, eventgrid_topic_endpoint):
akc_credential = AzureKeyCredential("bad credential")
client = EventGridPublisherClient(eventgrid_topic_endpoint, akc_credential)
client = EventGridClient(eventgrid_topic_endpoint, akc_credential, level=ClientLevel.BASIC)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand All @@ -71,9 +71,10 @@ async def test_raise_on_auth_error(self, eventgrid_topic_endpoint):
@pytest.mark.asyncio
async def test_raise_on_bad_resource(self):
credential = AzureKeyCredential(os.environ["EVENTGRID_TOPIC_KEY"])
client = EventGridPublisherClient(
client = EventGridClient(
"https://bad-resource.eastus-1.eventgrid.azure.net/api/events",
credential,
level=ClientLevel.BASIC,
)
eg_event = EventGridEvent(
subject="sample",
Expand Down

0 comments on commit bf94364

Please sign in to comment.