def test_map(self): # This is also test_lambda_expr (can't test that alone) self.assertEqual( self._q(query.map_(lambda a: query.multiply(2, a), [1, 2, 3])), [2, 4, 6]) self._create(n=10) self._create(n=10) self._create(n=10) page = query.paginate(query.match(self.n_index_ref, 10)) ns = query.map_(lambda a: query.select(["data", "n"], query.get(a)), page) self.assertEqual(self._q(ns), {"data": [10, 10, 10]})
def test_multiply(self): self.assertJson(query.multiply(1), '{"multiply":1}') self.assertJson(query.multiply(1, 2, 3), '{"multiply":[1,2,3]}') self.assertJson(query.multiply([1, 2, 3]), '{"multiply":[1,2,3]}')
def test_multiply(self): self.assertEqual(self._q(query.multiply(2, 3, 5)), 30) self._assert_bad_query(query.multiply())