Skip to content

Commit

Permalink
Merge pull request #1376 from dhermes/fix-1363
Browse files Browse the repository at this point in the history
Use runtime specific topic names in Pub/Sub system tests.
  • Loading branch information
dhermes committed Jan 20, 2016
2 parents fad4337 + 83bf30a commit 411fd38
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions system_tests/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from gcloud import pubsub


DEFAULT_TOPIC_NAME = 'subscribe-me%d' % (1000 * time.time(),)


class Config(object):
"""Run-time configuration to be modified at set-up.
Expand All @@ -45,13 +48,13 @@ def tearDown(self):
doomed.delete()

def test_create_topic(self):
TOPIC_NAME = 'a-new-topic'
topic = Config.CLIENT.topic(TOPIC_NAME)
topic_name = 'a-new-topic%d' % (1000 * time.time(),)
topic = Config.CLIENT.topic(topic_name)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
self.assertTrue(topic.exists())
self.assertEqual(topic.name, TOPIC_NAME)
self.assertEqual(topic.name, topic_name)

def test_list_topics(self):
topics_to_create = [
Expand All @@ -72,8 +75,7 @@ def test_list_topics(self):
self.assertEqual(len(created), len(topics_to_create))

def test_create_subscription_defaults(self):
TOPIC_NAME = 'subscribe-me'
topic = Config.CLIENT.topic(TOPIC_NAME)
topic = Config.CLIENT.topic(DEFAULT_TOPIC_NAME)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
Expand All @@ -87,8 +89,7 @@ def test_create_subscription_defaults(self):
self.assertTrue(subscription.topic is topic)

def test_create_subscription_w_ack_deadline(self):
TOPIC_NAME = 'subscribe-me'
topic = Config.CLIENT.topic(TOPIC_NAME)
topic = Config.CLIENT.topic(DEFAULT_TOPIC_NAME)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
Expand All @@ -103,8 +104,7 @@ def test_create_subscription_w_ack_deadline(self):
self.assertTrue(subscription.topic is topic)

def test_list_subscriptions(self):
TOPIC_NAME = 'subscribe-me'
topic = Config.CLIENT.topic(TOPIC_NAME)
topic = Config.CLIENT.topic(DEFAULT_TOPIC_NAME)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
Expand All @@ -122,12 +122,12 @@ def test_list_subscriptions(self):
all_subscriptions, _ = Config.CLIENT.list_subscriptions()
created = [subscription for subscription in all_subscriptions
if subscription.name in subscriptions_to_create and
subscription.topic.name == TOPIC_NAME]
subscription.topic.name == DEFAULT_TOPIC_NAME]
self.assertEqual(len(created), len(subscriptions_to_create))

def test_message_pull_mode_e2e(self):
TOPIC_NAME = 'subscribe-me'
topic = Config.CLIENT.topic(TOPIC_NAME, timestamp_messages=True)
topic = Config.CLIENT.topic(DEFAULT_TOPIC_NAME,
timestamp_messages=True)
self.assertFalse(topic.exists())
topic.create()
self.to_delete.append(topic)
Expand Down

0 comments on commit 411fd38

Please sign in to comment.