Esempio n. 1
0
 def test_on_start_no_sub_name(self):
     """Test the behavior of the on_start() handler when there is no subscription_name
     provided (a non-durable subscription)."""
     handler = ReceiverHandler(CONSUMER_CONFIG['urls'], 'test-topic',
                               Mock())
     event = Mock()
     handler.on_start(event)
     event.container.connect.assert_called_once_with(
         urls=CONSUMER_CONFIG['urls'], ssl_domain=None, heartbeat=500)
     conn = event.container.connect.return_value
     event.container.create_receiver.assert_called_once_with(conn,
                                                             'test-topic',
                                                             name=None,
                                                             options=[])
Esempio n. 2
0
 def test_on_start_sub_name(self):
     """Test the behavior of the on_start() handler when there is a subscription_name
     provided (a durable subscription)."""
     handler = ReceiverHandler(CONSUMER_CONFIG['urls'],
                               'test-topic',
                               Mock(),
                               subscription_name='test-sub')
     event = Mock()
     handler.on_start(event)
     event.container.container_id == 'test-sub'
     event.container.connect.assert_called_once_with(
         urls=CONSUMER_CONFIG['urls'], ssl_domain=None, heartbeat=500)
     conn = event.container.connect.return_value
     event.container.create_receiver.assert_called_once_with(
         conn, 'test-topic', name='test-sub', options=ANY)
     kwargs = event.container.create_receiver.call_args[1]
     opts = kwargs['options']
     self.assertEqual(len(opts), 1)
     self.assertIsInstance(opts[0], DurableSubscription)