コード例 #1
0
 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
     ])
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 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(),
                     '=@~']
コード例 #11
0
 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(), '=@~'
     ]
コード例 #12
0
 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])