Skip to content

Commit 70d9787

Browse files
committed
pep8 fixes, and tests changes, adding attribute _path
1 parent 3121e40 commit 70d9787

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

gcloud/pubsub/subscription.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, name, topic, ack_deadline=None, push_endpoint=None):
4545
self.topic = topic
4646
self.ack_deadline = ack_deadline
4747
self.push_endpoint = push_endpoint
48+
self._path = None
4849

4950
@classmethod
5051
def from_api_repr(cls, resource, topics=None):
@@ -76,17 +77,15 @@ def path(self):
7677
"""URL path for the subscription's APIs"""
7778
project = self.topic.project
7879
path = '/projects/%s/subscriptions/%s' % (project, self.name)
79-
if hasattr(self,"_path"):
80-
path = '/projects/%s/subscriptions/%s' % (project, self.name)
80+
if self._path is not None:
81+
path = self._path
8182
return path
8283

83-
8484
@path.setter
8585
def path(self, project):
8686
"""URL path setter"""
8787
self._path = '/projects/%s/subscriptions/%s' % (project, self.name)
8888

89-
9089
def create(self, connection=None):
9190
"""API call: create the subscription via a PUT request
9291

gcloud/pubsub/test_subscription.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,16 @@ def test_delete_w_explicit_connection(self):
458458

459459
def test_set_path_property(self):
460460
PROJECT = 'PROJECT'
461-
NEW_PROJECT = 'NEW_PROJECT'
461+
PROJECT2 = 'PROJECT2'
462462
SUB_NAME = 'sub_name'
463463
SUB_PATH = '/projects/%s/subscriptions/%s' % (PROJECT, SUB_NAME)
464-
NEW_SUB_PATH = '/projects/%s/subscriptions/%s' % (NEW_PROJECT, SUB_NAME)
464+
SUB_PATH2 = '/projects/%s/subscriptions/%s' % (PROJECT2, SUB_NAME)
465465
TOPIC_NAME = 'topic_name'
466-
conn = _Connection({})
467466
topic = _Topic(TOPIC_NAME, project=PROJECT)
468467
subscription = self._makeOne(SUB_NAME, topic)
469-
self.assertEqual(SUB_PATH ,subscription.path)
470-
subscription.path = NEW_PROJECT
471-
self.assertEqual(NEW_SUB_PATH, subscription.path)
468+
self.assertEqual(SUB_PATH, subscription.path)
469+
subscription.path = PROJECT2
470+
self.assertEqual(SUB_PATH2, subscription.path)
472471

473472

474473
class _Connection(object):

0 commit comments

Comments
 (0)