@@ -50,7 +50,6 @@ def test_list_topics(self):
5050 'newer%d' % (1000 * time .time (),),
5151 'newest%d' % (1000 * time .time (),),
5252 ]
53- created_topics = []
5453 for topic_name in topics_to_create :
5554 topic = Topic (topic_name )
5655 topic .create ()
@@ -59,10 +58,10 @@ def test_list_topics(self):
5958 # Retrieve the topics.
6059 all_topics , _ = pubsub .list_topics ()
6160 project_id = pubsub .get_default_project ()
62- created_topics = [topic for topic in all_topics
63- if topic .name in topics_to_create and
64- topic .project == project_id ]
65- self .assertEqual (len (created_topics ), len (topics_to_create ))
61+ created = [topic for topic in all_topics
62+ if topic .name in topics_to_create and
63+ topic .project == project_id ]
64+ self .assertEqual (len (created ), len (topics_to_create ))
6665
6766 def test_create_subscription (self ):
6867 TOPIC_NAME = 'subscribe-me'
@@ -78,3 +77,26 @@ def test_create_subscription(self):
7877 self .assertTrue (subscription .exists ())
7978 self .assertEqual (subscription .name , SUBSCRIPTION_NAME )
8079 self .assertTrue (subscription .topic is topic )
80+
81+ def test_list_subscriptions (self ):
82+ TOPIC_NAME = 'subscribe-me'
83+ topic = Topic (TOPIC_NAME )
84+ self .assertFalse (topic .exists ())
85+ topic .create ()
86+ self .to_delete .append (topic )
87+ subscriptions_to_create = [
88+ 'new%d' % (1000 * time .time (),),
89+ 'newer%d' % (1000 * time .time (),),
90+ 'newest%d' % (1000 * time .time (),),
91+ ]
92+ for subscription_name in subscriptions_to_create :
93+ subscription = Subscription (subscription_name , topic )
94+ subscription .create ()
95+ self .to_delete .append (subscription )
96+
97+ # Retrieve the subscriptions.
98+ all_subscriptions , _ = pubsub .list_subscriptions ()
99+ created = [subscription for subscription in all_subscriptions
100+ if subscription .name in subscriptions_to_create and
101+ subscription .topic .name == TOPIC_NAME ]
102+ self .assertEqual (len (created ), len (subscriptions_to_create ))
0 commit comments