def test_queue_max_equal(self): mock_logger = mock.Mock(spec=Logger) SUT = TopicManager(self.config, mock_logger) queue = deque() queue.append(''.join([ random.choice(string.ascii_letters + string.digits) for n in range(32) ]), ) # pylint: disable=unused-variable queue.append( ''.join([ random.choice(string.ascii_letters + string.digits) for n in range(32) ]), ) queue.append( ''.join([ random.choice(string.ascii_letters + string.digits) for n in range(32) ]), ) queue.append( ''.join([ random.choice(string.ascii_letters + string.digits) for n in range(32) ]), ) orig_queue_size = len(queue) max_queue = 4 SUT._queue_size_check(queue, max_queue) # pylint: disable=protected-access self.assertEqual(mock_logger.error.call_count, orig_queue_size - max_queue + 1) self.assertEqual(len(queue), max_queue - 1)
def test_queue_max_not_reached(self): mock_logger = mock.Mock(spec=Logger) SUT = TopicManager(None, self.config, mock_logger) queue = deque() queue.append(random_string(), ) queue.append(random_string(), ) queue.append(random_string(), ) queue.append(random_string(), ) orig_queue_size = len(queue) max_queue = 7 SUT._queue_size_check(queue, max_queue) # pylint: disable=protected-access self.assertEqual(mock_logger.error.call_count, 0) self.assertEqual(len(queue), orig_queue_size)