Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speling: pass 'ack_deadline' as 'ackDeadlineSeconds' everywhere. #1182

Merged
merged 2 commits into from
Oct 15, 2015
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
4 changes: 2 additions & 2 deletions gcloud/pubsub/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def create(self, client=None):
data = {'topic': self.topic.full_name}

if self.ack_deadline is not None:
data['ackDeadline'] = self.ack_deadline
data['ackDeadlineSeconds'] = self.ack_deadline

if self.push_endpoint is not None:
data['pushConfig'] = {'pushEndpoint': self.push_endpoint}
Expand Down Expand Up @@ -150,7 +150,7 @@ def reload(self, client=None):
"""
client = self._require_client(client)
data = client.connection.api_request(method='GET', path=self.path)
self.ack_deadline = data.get('ackDeadline')
self.ack_deadline = data.get('ackDeadlineSeconds')
push_config = data.get('pushConfig', {})
self.push_endpoint = push_config.get('pushEndpoint')

Expand Down
6 changes: 3 additions & 3 deletions gcloud/pubsub/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_create_push_w_ack_deadline_w_alternate_client(self):
DEADLINE = 42
ENDPOINT = 'https://api.example.com/push'
BODY = {'topic': TOPIC_PATH,
'ackDeadline': DEADLINE,
'ackDeadlineSeconds': DEADLINE,
'pushConfig': {'pushEndpoint': ENDPOINT}}
conn1 = _Connection({'name': SUB_PATH})
CLIENT1 = _Client(project=PROJECT, connection=conn1)
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_reload_w_bound_client(self):
ENDPOINT = 'https://api.example.com/push'
conn = _Connection({'name': SUB_PATH,
'topic': TOPIC_PATH,
'ackDeadline': DEADLINE,
'ackDeadlineSeconds': DEADLINE,
'pushConfig': {'pushEndpoint': ENDPOINT}})
CLIENT = _Client(project=PROJECT, connection=conn)
topic = _Topic(TOPIC_NAME, client=CLIENT)
Expand All @@ -230,7 +230,7 @@ def test_reload_w_alternate_client(self):
CLIENT1 = _Client(project=PROJECT, connection=conn1)
conn2 = _Connection({'name': SUB_PATH,
'topic': TOPIC_PATH,
'ackDeadline': DEADLINE,
'ackDeadlineSeconds': DEADLINE,
'pushConfig': {'pushEndpoint': ENDPOINT}})
CLIENT2 = _Client(project=PROJECT, connection=conn2)
topic = _Topic(TOPIC_NAME, client=CLIENT1)
Expand Down
18 changes: 17 additions & 1 deletion system_tests/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_list_topics(self):
topic.project == CLIENT.project]
self.assertEqual(len(created), len(topics_to_create))

def test_create_subscription(self):
def test_create_subscription_defaults(self):
TOPIC_NAME = 'subscribe-me'
topic = CLIENT.topic(TOPIC_NAME)
self.assertFalse(topic.exists())
Expand All @@ -76,6 +76,22 @@ def test_create_subscription(self):
self.assertEqual(subscription.name, SUBSCRIPTION_NAME)
self.assertTrue(subscription.topic is topic)

def test_create_subscription_w_ack_deadline(self):
TOPIC_NAME = 'subscribe-me'
topic = CLIENT.topic(TOPIC_NAME)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
SUBSCRIPTION_NAME = 'subscribing-now'
subscription = topic.subscription(SUBSCRIPTION_NAME, ack_deadline=120)
self.assertFalse(subscription.exists())
subscription.create()
self.to_delete.append(subscription)
self.assertTrue(subscription.exists())
self.assertEqual(subscription.name, SUBSCRIPTION_NAME)
self.assertEqual(subscription.ack_deadline, 120)
self.assertTrue(subscription.topic is topic)

def test_list_subscriptions(self):
TOPIC_NAME = 'subscribe-me'
topic = CLIENT.topic(TOPIC_NAME)
Expand Down