Skip to content

Commit

Permalink
Add test for creating non-default subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Jun 11, 2019
1 parent 7b51a19 commit a57c9f1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pubsub/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,42 @@ def test_subscribe_to_messages_async_callbacks(
future.cancel()


def test_creating_subscriptions_with_non_default_settings(
publisher, subscriber, project, topic_path, subscription_path, cleanup
):
# Make sure the topic and subscription get deleted.
cleanup.append((publisher.delete_topic, topic_path))
cleanup.append((subscriber.delete_subscription, subscription_path))

# create a topic and a subscription, customize the latter's policy
publisher.create_topic(topic_path)

msg_retention_duration = {"seconds": 911}
expiration_policy = {"ttl": {"seconds": 90210}}
new_subscription = subscriber.create_subscription(
subscription_path,
topic_path,
ack_deadline_seconds=30,
retain_acked_messages=True,
message_retention_duration=msg_retention_duration,
expiration_policy=expiration_policy,
)

# fetch the subscription and check its settings
project_path = subscriber.project_path(project)
subscriptions = subscriber.list_subscriptions(project_path)

subscriptions = [sub for sub in subscriptions if sub.topic == topic_path]
assert len(subscriptions) == 1
subscription = subscriptions[0]

assert subscription == new_subscription
assert subscription.ack_deadline_seconds == 30
assert subscription.retain_acked_messages
assert subscription.message_retention_duration.seconds == 911
assert subscription.expiration_policy.ttl.seconds == 90210


def test_listing_project_topics(publisher, project, cleanup):
topic_paths = [
publisher.topic_path(project, "topic-{}".format(i) + unique_resource_id("."))
Expand Down

0 comments on commit a57c9f1

Please sign in to comment.