def test_create_batch_for_select_with_additional_spaces(self): batch_text = ' Select * from t1 ' batch = create_batch(batch_text, 0, self._selection_data, self._batch_events, ResultSetStorageType.IN_MEMORY) self.assertTrue(isinstance(batch, SelectBatch))
def test_create_batch_for_non_select(self): batch_text = 'Insert into t1 values(1)' batch = create_batch(batch_text, 0, self._selection_data, self._batch_events, ResultSetStorageType.IN_MEMORY) self.assertFalse(isinstance(batch, SelectBatch)) self.assertTrue(isinstance(batch, Batch))
def test_create_batch_for_select_into(self): batch_text = ' Select into temptable from t1 ' batch = create_batch(batch_text, 0, self._selection_data, self._batch_events, ResultSetStorageType.IN_MEMORY) self.assertFalse(isinstance(batch, SelectBatch)) self.assertTrue(isinstance(batch, Batch))
def test_get_subset(self): expected_subset = [] batch = create_batch('select 1', 0, self._selection_data, self._batch_events, ResultSetStorageType.IN_MEMORY) self._result_set.get_subset = mock.Mock(return_value=expected_subset) batch._result_set = self._result_set subset = batch.get_subset(0, 10) self.assertEqual(expected_subset, subset) self._result_set.get_subset.assert_called_once_with(0, 10)