def execute_get_subset_raises_error_when_index_not_in_range( self, batch_index: int): full_query = 'Select * from t1;' query = Query('test_uri', full_query, QueryExecutionSettings(ExecutionPlanOptions(), None), QueryEvents()) with self.assertRaises(IndexError) as context_manager: query.get_subset(batch_index, 0, 10) self.assertEquals( 'Batch index cannot be less than 0 or greater than the number of batches', context_manager.exception.args[0])
def test_get_subset(self): full_query = 'Select * from t1;' query = Query('test_uri', full_query, QueryExecutionSettings(ExecutionPlanOptions(), None), QueryEvents()) expected_subset = [] mock_batch = mock.MagicMock() mock_batch.get_subset = mock.Mock(return_value=expected_subset) query._batches = [mock_batch] subset = query.get_subset(0, 0, 10) self.assertEqual(expected_subset, subset) mock_batch.get_subset.assert_called_once_with(0, 10)