Ejemplo n.º 1
0
    def test_close(self):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()

        # test
        consumer._close()

        # validation
        consumer._reader.close.assert_called_once_with()
Ejemplo n.º 2
0
    def test_close(self):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()

        # test
        consumer._close()

        # validation
        consumer._reader.close.assert_called_once_with()
Ejemplo n.º 3
0
    def test_close_exception(self):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()
        consumer._reader.close.side_effect = ValueError

        # test
        consumer._close()

        # validation
        consumer._reader.close.assert_called_once_with()
Ejemplo n.º 4
0
    def test_close_exception(self):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()
        consumer._reader.close.side_effect = ValueError

        # test
        consumer._close()

        # validation
        consumer._reader.close.assert_called_once_with()
Ejemplo n.º 5
0
    def test_read_exception(self, sleep):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()
        consumer._reader.next.side_effect = IndexError
        consumer._open = Mock()
        consumer._close = Mock()

        # test
        consumer._read()

        # validation
        consumer._close.assert_called_once_with()
        consumer._open.assert_called_once_with()
        sleep.assert_called_once_with(60)
Ejemplo n.º 6
0
    def test_read_exception(self, sleep):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._reader = Mock()
        consumer._reader.next.side_effect = IndexError
        consumer._open = Mock()
        consumer._close = Mock()

        # test
        consumer._read()

        # validation
        consumer._close.assert_called_once_with()
        consumer._open.assert_called_once_with()
        sleep.assert_called_once_with(60)
Ejemplo n.º 7
0
    def test_run(self, reader):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._open = Mock()
        consumer._close = Mock()
        consumer._read = Mock(side_effect=StopIteration)

        # test
        try:
            consumer.run()
        except StopIteration:
            pass

        # validation
        reader.assert_called_once_with(node, url)
        consumer._open.assert_called_once_with()
        consumer._read.assert_called_once_with()
        consumer._close.assert_called_once_with()
Ejemplo n.º 8
0
    def test_run(self, reader):
        url = 'test-url'
        node = Node('test-queue')
        consumer = ConsumerThread(node, url)
        consumer._open = Mock()
        consumer._close = Mock()
        consumer._read = Mock(side_effect=StopIteration)

        # test
        try:
            consumer.run()
        except StopIteration:
            pass

        # validation
        reader.assert_called_once_with(node, url)
        consumer._open.assert_called_once_with()
        consumer._read.assert_called_once_with()
        consumer._close.assert_called_once_with()