Skip to content

Commit

Permalink
Add regression test for pubsub.api.list_topics.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Mar 31, 2015
1 parent 69c5537 commit 3252115
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcloud/pubsub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
22 changes: 22 additions & 0 deletions regression/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

0 comments on commit 3252115

Please sign in to comment.