def test_timeout(self): mock_queue = ["one"] mock_batcher = mock.MagicMock() mock_batcher.batch_age = 60 injector.consume_items_in_batches(mock_queue, mock_batcher) self.assertEqual(mock_batcher.add.call_count, 1) self.assertTrue(mock_batcher.flush.called)
def test_no_timeout(self): mock_queue = ["one", "two", "three"] mock_batcher = mock.MagicMock() mock_batcher.batch_age = 0 injector.consume_items_in_batches(mock_queue, mock_batcher) self.assertEqual(mock_batcher.add.call_count, 3) self.assertFalse(mock_batcher.flush.called)