Beispiel #1
0
class DescribeOnConnectionFailure(_BaseTestCase):
    __contexts__ = (
        ('time', patch(mod + '.time')),
        ('exit', patch(mod + '.sys.exit')),
    )

    def configure(self):
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.add_on_connection_close_callback = MagicMock()
        self.agent.open_channel = MagicMock()

    def execute(self):
        self.agent.on_connection_failure(sentinel.exc)

    def should_sleep(self):
        self.ctx.time.sleep.assert_called_once_with(
            ConsumerAgent._RECONNECT_DELAY)

    def should_exit(self):
        self.ctx.exit.assert_called_once_with()
Beispiel #2
0
class DescribeOnConnectionFailure(_BaseTestCase):
    __contexts__ = (
        ('time', patch(mod + '.time')),
        ('exit', patch(mod + '.sys.exit')),
    )

    def configure(self):
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.add_on_connection_close_callback = MagicMock()
        self.agent.open_channel = MagicMock()

    def execute(self):
        self.agent.on_connection_failure(sentinel.exc)

    def should_sleep(self):
        self.ctx.time.sleep.assert_called_once_with(
            ConsumerAgent._RECONNECT_DELAY
        )

    def should_exit(self):
        self.ctx.exit.assert_called_once_with()