Exemple #1
0
 def test_as_logger(self):
     with patch('amqp.utils.NullHandler') as _NullHandler:
         m = Mock(name='logger')
         m.handlers = None
         x = get_logger(m)
         assert x is m
         x.addHandler.assert_called_with(_NullHandler())
Exemple #2
0
    def test_handle_event(self):
        p = self.Poller()
        chan = Mock(name='chan')
        p._fd_to_chan[13] = chan, 'BRPOP'
        chan.handlers = {'BRPOP': Mock(name='BRPOP')}

        chan.qos.can_consume.return_value = False
        p.handle_event(13, redis.READ)
        chan.handlers['BRPOP'].assert_not_called()

        chan.qos.can_consume.return_value = True
        p.handle_event(13, redis.READ)
        chan.handlers['BRPOP'].assert_called_with()

        p.handle_event(13, redis.ERR)
        chan._poll_error.assert_called_with('BRPOP')

        p.handle_event(13, ~(redis.READ | redis.ERR))
Exemple #3
0
 def test_as_logger(self, _NullHandler):
     m = Mock(name='logger')
     m.handlers = None
     x = get_logger(m)
     assert x is m
     x.addHandler.assert_called_with(_NullHandler())