def tearDownClass(cls): """Delete resources used in the tests.""" main(['pubsub_sample.py', get_project_id(), 'delete_topic', cls.topic]) main([ 'pubsub_sample.py', get_project_id(), 'delete_subscription', cls.sub ])
def test_list_subscriptions(self): """Test the list_subscriptions action.""" expected_sub = ('projects/%s/subscriptions/%s' % (get_project_id(), self.sub)) with captured_output() as (out, _): main(['pubsub_sample.py', get_project_id(), 'list_subscriptions']) output = out.getvalue().strip() self.assertTrue(expected_sub in output)
def test_list_topics(self): """Test the list_topics action.""" expected_topic = ('projects/%s/topics/%s' % (get_project_id(), self.topic)) with captured_output() as (out, _): main(['pubsub_sample.py', get_project_id(), 'list_topics']) output = out.getvalue().strip() self.assertTrue(expected_topic in output)
def test_pull_message(self): """Try to pull messages from a subscription.""" with captured_output() as (out, _): main(['pubsub_sample.py', get_project_id(), 'pull_messages', self.sub, '-n']) output = out.getvalue().strip() for message in self.messages: self.assertTrue(message in output)
def test_publish_message(self): """Try to publish a message and check the output for the message.""" for message in self.messages: with captured_output() as (out, _): main(['pubsub_sample.py', get_project_id(), 'publish_message', self.topic, message]) output = out.getvalue().strip() self.assertTrue(message in output)
def test_publish_message(self): """Try to publish a message and check the output for the message.""" for message in self.messages: with captured_output() as (out, _): main([ 'pubsub_sample.py', get_project_id(), 'publish_message', self.topic, message ]) output = out.getvalue().strip() self.assertTrue(message in output)
def test_pull_message(self): """Try to pull messages from a subscription.""" with captured_output() as (out, _): main([ 'pubsub_sample.py', get_project_id(), 'pull_messages', self.sub, '-n' ]) output = out.getvalue().strip() for message in self.messages: self.assertTrue(message in output)
def setUpClass(cls): """Create a new topic and subscription with a random name.""" random_id = uuid.uuid4() cls.topic = 'topic-%s' % random_id cls.sub = 'sub-%s' % random_id main(['pubsub_sample.py', get_project_id(), 'create_topic', cls.topic]) main(['pubsub_sample.py', get_project_id(), 'create_subscription', cls.sub, cls.topic]) # The third message is to check the consistency between base64 # variants used on the server side and the client side. cls.messages = ['message-1-%s' % uuid.uuid4(), 'message-2-%s' % uuid.uuid4(), '=@~']
def setUpClass(cls): """Create a new topic and subscription with a random name.""" random_id = uuid.uuid4() cls.topic = 'topic-%s' % random_id cls.sub = 'sub-%s' % random_id main(['pubsub_sample.py', get_project_id(), 'create_topic', cls.topic]) main([ 'pubsub_sample.py', get_project_id(), 'create_subscription', cls.sub, cls.topic ]) # The third message is to check the consistency between base64 # variants used on the server side and the client side. cls.messages = [ 'message-1-%s' % uuid.uuid4(), 'message-2-%s' % uuid.uuid4(), '=@~' ]
def tearDownClass(cls): """Delete resources used in the tests.""" main(['pubsub_sample.py', get_project_id(), 'delete_topic', cls.topic]) main(['pubsub_sample.py', get_project_id(), 'delete_subscription', cls.sub])