From 9f772688252515eecf7bcc21b691760bec3664ec Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 31 Mar 2015 15:33:31 -0400 Subject: [PATCH] Add regression test for pubsub.api.list_topics. --- gcloud/pubsub/__init__.py | 1 + regression/pubsub.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gcloud/pubsub/__init__.py b/gcloud/pubsub/__init__.py index fb9965ac8b90..ffc96aa890c8 100644 --- a/gcloud/pubsub/__init__.py +++ b/gcloud/pubsub/__init__.py @@ -29,6 +29,7 @@ from gcloud.connection import get_scoped_connection from gcloud.pubsub import _implicit_environ from gcloud.pubsub._implicit_environ import get_default_connection +from gcloud.pubsub.api import list_topics from gcloud.pubsub.connection import Connection diff --git a/regression/pubsub.py b/regression/pubsub.py index 116b9329204e..7df330986787 100644 --- a/regression/pubsub.py +++ b/regression/pubsub.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time + import unittest2 from gcloud import _helpers @@ -40,3 +42,23 @@ def test_create_topic(self): self.to_delete.append(topic) self.assertTrue(topic.exists()) self.assertEqual(topic.name, new_topic_name) + + def test_list_topics(self): + topics_to_create = [ + 'new%d' % (1000 * time.time(),), + 'newer%d' % (1000 * time.time(),), + 'newest%d' % (1000 * time.time(),), + ] + created_topics = [] + for topic_name in topics_to_create: + topic = Topic(topic_name) + topic.create() + self.to_delete.append(topic) + + # Retrieve the topics. + all_topics, _ = pubsub.list_topics() + project_id = pubsub.get_default_project() + created_topics = [topic for topic in all_topics + if topic.name in topics_to_create and + topic.project == project_id] + self.assertEqual(len(created_topics), len(topics_to_create))