@@ -292,21 +292,28 @@ def test_topic_publish_error(self):
292292 def test_topic_list_subscriptions_no_paging (self ):
293293 from google .gax import INITIAL_PAGE
294294 from google .cloud ._testing import _GAXPageIterator
295- response = _GAXPageIterator (
296- [{'name' : self .SUB_PATH , 'topic' : self .TOPIC_PATH }])
295+ from google .cloud .pubsub .subscription import Subscription
296+ from google .cloud .pubsub .topic import Topic
297+
298+ local_sub_path = '%s/subscriptions/%s' % (
299+ self .PROJECT_PATH , self .SUB_NAME )
300+ response = _GAXPageIterator ([local_sub_path ])
297301 gax_api = _GAXPublisherAPI (_list_topic_subscriptions_response = response )
298302 client = _Client (self .PROJECT )
299303 api = self ._makeOne (gax_api , client )
300304
301- subscriptions , next_token = api .topic_list_subscriptions (
302- self .TOPIC_PATH )
305+ topic = Topic (self .TOPIC_NAME , client )
306+ iterator = api .topic_list_subscriptions (topic )
307+ subscriptions = list (iterator )
308+ next_token = iterator .next_page_token
303309
310+ self .assertIsNone (next_token )
304311 self .assertEqual (len (subscriptions ), 1 )
305312 subscription = subscriptions [0 ]
306- self .assertIsInstance (subscription , dict )
307- self .assertEqual (subscription [ ' name' ] , self .SUB_PATH )
308- self .assertEqual (subscription [ ' topic' ], self . TOPIC_PATH )
309- self .assertIsNone ( next_token )
313+ self .assertIsInstance (subscription , Subscription )
314+ self .assertEqual (subscription . name , self .SUB_NAME )
315+ self .assertEqual (subscription . topic , topic )
316+ self .assertIs ( subscription . _client , client )
310317
311318 topic_path , page_size , options = (
312319 gax_api ._list_topic_subscriptions_called_with )
@@ -316,25 +323,33 @@ def test_topic_list_subscriptions_no_paging(self):
316323
317324 def test_topic_list_subscriptions_with_paging (self ):
318325 from google .cloud ._testing import _GAXPageIterator
326+ from google .cloud .pubsub .subscription import Subscription
327+ from google .cloud .pubsub .topic import Topic
328+
319329 SIZE = 23
320330 TOKEN = 'TOKEN'
321331 NEW_TOKEN = 'NEW_TOKEN'
332+ local_sub_path = '%s/subscriptions/%s' % (
333+ self .PROJECT_PATH , self .SUB_NAME )
322334 response = _GAXPageIterator (
323- [{'name' : self .SUB_PATH , 'topic' : self .TOPIC_PATH }],
324- page_token = NEW_TOKEN )
335+ [local_sub_path ], page_token = NEW_TOKEN )
325336 gax_api = _GAXPublisherAPI (_list_topic_subscriptions_response = response )
326337 client = _Client (self .PROJECT )
327338 api = self ._makeOne (gax_api , client )
328339
329- subscriptions , next_token = api .topic_list_subscriptions (
330- self .TOPIC_PATH , page_size = SIZE , page_token = TOKEN )
340+ topic = Topic (self .TOPIC_NAME , client )
341+ iterator = api .topic_list_subscriptions (
342+ topic , page_size = SIZE , page_token = TOKEN )
343+ subscriptions = list (iterator )
344+ next_token = iterator .next_page_token
331345
346+ self .assertEqual (next_token , NEW_TOKEN )
332347 self .assertEqual (len (subscriptions ), 1 )
333348 subscription = subscriptions [0 ]
334- self .assertIsInstance (subscription , dict )
335- self .assertEqual (subscription [ ' name' ] , self .SUB_PATH )
336- self .assertEqual (subscription [ ' topic' ], self . TOPIC_PATH )
337- self .assertEqual ( next_token , NEW_TOKEN )
349+ self .assertIsInstance (subscription , Subscription )
350+ self .assertEqual (subscription . name , self .SUB_NAME )
351+ self .assertEqual (subscription . topic , topic )
352+ self .assertIs ( subscription . _client , client )
338353
339354 name , page_size , options = (
340355 gax_api ._list_topic_subscriptions_called_with )
@@ -345,12 +360,15 @@ def test_topic_list_subscriptions_with_paging(self):
345360 def test_topic_list_subscriptions_miss (self ):
346361 from google .gax import INITIAL_PAGE
347362 from google .cloud .exceptions import NotFound
363+ from google .cloud .pubsub .topic import Topic
364+
348365 gax_api = _GAXPublisherAPI ()
349366 client = _Client (self .PROJECT )
350367 api = self ._makeOne (gax_api , client )
351368
352369 with self .assertRaises (NotFound ):
353- api .topic_list_subscriptions (self .TOPIC_PATH )
370+ topic = Topic (self .TOPIC_NAME , client )
371+ api .topic_list_subscriptions (topic )
354372
355373 topic_path , page_size , options = (
356374 gax_api ._list_topic_subscriptions_called_with )
@@ -361,12 +379,15 @@ def test_topic_list_subscriptions_miss(self):
361379 def test_topic_list_subscriptions_error (self ):
362380 from google .gax import INITIAL_PAGE
363381 from google .gax .errors import GaxError
382+ from google .cloud .pubsub .topic import Topic
383+
364384 gax_api = _GAXPublisherAPI (_random_gax_error = True )
365385 client = _Client (self .PROJECT )
366386 api = self ._makeOne (gax_api , client )
367387
368388 with self .assertRaises (GaxError ):
369- api .topic_list_subscriptions (self .TOPIC_PATH )
389+ topic = Topic (self .TOPIC_NAME , client )
390+ api .topic_list_subscriptions (topic )
370391
371392 topic_path , page_size , options = (
372393 gax_api ._list_topic_subscriptions_called_with )
0 commit comments