Skip to content
Merged
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
25 changes: 23 additions & 2 deletions samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
SUBSCRIPTION_EOD = f"subscription-test-subscription-eod-{PY_VERSION}-{UUID}"
ENDPOINT = f"https://{PROJECT_ID}.appspot.com/push"
NEW_ENDPOINT = f"https://{PROJECT_ID}.appspot.com/push2"
REGIONAL_ENDPOINT = "us-east1-pubsub.googleapis.com:443"
DEFAULT_MAX_DELIVERY_ATTEMPTS = 5
UPDATED_MAX_DELIVERY_ATTEMPTS = 20
FILTER = 'attributes.author="unknown"'
Expand All @@ -59,7 +60,7 @@ def publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]:

@pytest.fixture(scope="module")
def regional_publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]:
client_options = {"api_endpoint": "us-east1-pubsub.googleapis.com:443"}
client_options = {"api_endpoint": REGIONAL_ENDPOINT}
publisher = pubsub_v1.PublisherClient(client_options=client_options)
yield publisher

Expand Down Expand Up @@ -703,7 +704,8 @@ def eventually_consistent_test() -> None:
eventually_consistent_test()


def test_receive_messages_with_exactly_once_delivery_enabled(
@typed_flaky
def test_receive_messages_with_exactly_once_delivery_enabled_regional_endpoint(
regional_publisher_client: pubsub_v1.PublisherClient,
exactly_once_delivery_topic: str,
subscription_eod: str,
Expand All @@ -722,6 +724,25 @@ def test_receive_messages_with_exactly_once_delivery_enabled(
assert message_id in out


def test_receive_messages_with_exactly_once_delivery_enabled(
publisher_client: pubsub_v1.PublisherClient,
exactly_once_delivery_topic: str,
subscription_eod: str,
capsys: CaptureFixture[str],
) -> None:

message_ids = _publish_messages(publisher_client, exactly_once_delivery_topic)

subscriber.receive_messages_with_exactly_once_delivery_enabled(
PROJECT_ID, SUBSCRIPTION_EOD, 10
)

out, _ = capsys.readouterr()
assert subscription_eod in out
for message_id in message_ids:
assert message_id in out


def test_listen_for_errors(
publisher_client: pubsub_v1.PublisherClient,
topic: str,
Expand Down