File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 2929from gcloud .connection import get_scoped_connection
3030from gcloud .pubsub import _implicit_environ
3131from gcloud .pubsub ._implicit_environ import get_default_connection
32+ from gcloud .pubsub .api import list_topics
3233from gcloud .pubsub .connection import Connection
3334
3435
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import time
16+
1517import unittest2
1618
1719from gcloud import _helpers
@@ -40,3 +42,23 @@ def test_create_topic(self):
4042 self .to_delete .append (topic )
4143 self .assertTrue (topic .exists ())
4244 self .assertEqual (topic .name , new_topic_name )
45+
46+ def test_list_topics (self ):
47+ topics_to_create = [
48+ 'new%d' % (1000 * time .time (),),
49+ 'newer%d' % (1000 * time .time (),),
50+ 'newest%d' % (1000 * time .time (),),
51+ ]
52+ created_topics = []
53+ for topic_name in topics_to_create :
54+ topic = Topic (topic_name )
55+ topic .create ()
56+ self .to_delete .append (topic )
57+
58+ # Retrieve the topics.
59+ all_topics , _ = pubsub .list_topics ()
60+ project_id = pubsub .get_default_project ()
61+ created_topics = [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_topics ), len (topics_to_create ))
You can’t perform that action at this time.
0 commit comments