def test_fetch_datasource(self): select = Selector([('A', 'B'), ('1', '2'), ('1', '2')]) query = Query(select, ['B']) query._query_steps = [ ('map', (int, ), {}), ('map', (lambda x: x * 2, ), {}), ('sum', (), {}), ] result = query.fetch() self.assertEqual(result, 8)
def test_execute_datasource(self): select = Selector([('A', 'B'), ('1', '2'), ('1', '2')]) query = Query(select, ['B']) query._query_steps = [ ('map', (int, ), {}), ('map', (lambda x: x * 2, ), {}), ('sum', (), {}), ] result = query.execute() self.assertEqual(result, 8) query = Query(['A']) regex = "expected 'Selector', got 'list'" with self.assertRaisesRegex(TypeError, regex): query.execute(['hello', 'world']) # <- Expects None or Query, not list!