Ejemplo n.º 1
0
    def test_expr_function_arity(self):
        # Compile with the correct number of arguments.
        qc.compile_expression(qp.Function('sum', [qp.Column('number')]),
                              qe.TargetsEnvironment())

        # Compile with an incorrect number of arguments.
        with self.assertRaises(qc.CompilationError):
            qc.compile_expression(
                qp.Function('sum', [qp.Column('date'),
                                    qp.Column('account')]),
                qe.TargetsEnvironment())
Ejemplo n.º 2
0
 def test_expr_binaryop(self):
     self.assertEqual(
         qc.EvalEqual(qe.DateColumn(),
                      qc.EvalConstant(datetime.date(2014, 1, 1))),
         qc.compile_expression(
             qp.Equal(qp.Column('date'),
                      qp.Constant(datetime.date(2014, 1, 1))),
             qe.TargetsEnvironment()))
Ejemplo n.º 3
0
 def test_expr_constant(self):
     self.assertEqual(
         qc.EvalConstant(D(17)),
         qc.compile_expression(qp.Constant(D(17)), qe.TargetsEnvironment()))
Ejemplo n.º 4
0
 def test_expr_unaryop(self):
     self.assertEqual(
         qc.EvalNot(qe.AccountColumn()),
         qc.compile_expression(qp.Not(qp.Column('account')),
                               qe.TargetsEnvironment()))
Ejemplo n.º 5
0
 def test_expr_function(self):
     self.assertEqual(
         qe.SumPosition([qe.PositionColumn()]),
         qc.compile_expression(qp.Function('sum', [qp.Column('position')]),
                               qe.TargetsEnvironment()))
Ejemplo n.º 6
0
 def test_expr_column(self):
     self.assertEqual(
         qe.FilenameColumn(),
         qc.compile_expression(qp.Column('filename'),
                               qe.TargetsEnvironment()))
Ejemplo n.º 7
0
 def test_expr_invalid(self):
     with self.assertRaises(qc.CompilationError):
         qc.compile_expression(qp.Column('invalid'),
                               qe.TargetsEnvironment())