Beispiel #1
0
 def test_parse_string_to_date(self):
     expected_expression = \
         sqla_op.gt(self.model._updated,
                    str_to_date('Sun, 06 Nov 1994 08:49:37 GMT'))
     r = parse('_updated > "Sun, 06 Nov 1994 08:49:37 GMT"', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))
Beispiel #2
0
 def test_parse_string_to_date(self):
     expected_expression = \
         sqla_op.gt(self.model._updated,
                    str_to_date('Sun, 06 Nov 1994 08:49:37 GMT'))
     r = parse('_updated > "Sun, 06 Nov 1994 08:49:37 GMT"', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))
Beispiel #3
0
 def test_or_bool_op(self):
     r = parse('username == "john" or prog == 5', self.model)
     self.assertEqual(type(r), list)
     self.assertEqual(type(r[0]), BooleanClauseList)
     self.assertEqual(r[0].operator, or_)
     self.assertEqual(len(r[0].clauses), 2)
     expected_expression = sqla_op.eq(self.model.username, 'john')
     self.assertTrue(expected_expression.compare(r[0].clauses[0]))
     expected_expression = sqla_op.eq(self.model.prog, 5)
     self.assertTrue(expected_expression.compare(r[0].clauses[1]))
Beispiel #4
0
 def test_or_bool_op(self):
     r = parse('firstname == "john" or prog == 5', self.model)
     self.assertEqual(type(r), list)
     self.assertEqual(type(r[0]), BooleanClauseList)
     self.assertEqual(r[0].operator, or_)
     self.assertEqual(len(r[0].clauses), 2)
     expected_expression = sqla_op.eq(self.model.firstname, 'john')
     self.assertTrue(expected_expression.compare(r[0].clauses[0]))
     expected_expression = sqla_op.eq(self.model.prog, 5)
     self.assertTrue(expected_expression.compare(r[0].clauses[1]))
Beispiel #5
0
 def test_nested_bool_op(self):
     r = parse('username == "john" or (prog == 5 and ref == "smith")',
               self.model)
     self.assertEqual(type(r), list)
     self.assertEqual(type(r[0]), BooleanClauseList)
     self.assertEqual(r[0].operator, or_)
     self.assertEqual(len(r[0].clauses), 2)
     expected_expression = sqla_op.eq(self.model.username, 'john')
     self.assertTrue(expected_expression.compare(r[0].clauses[0]))
     second_op = r[0].clauses[1]
     self.assertEqual(type(second_op), BooleanClauseList)
     self.assertEqual(second_op.operator, and_)
     self.assertEqual(len(second_op.clauses), 2)
     expected_expression = sqla_op.eq(self.model.prog, 5)
     self.assertTrue(expected_expression.compare(second_op.clauses[0]))
     expected_expression = sqla_op.eq(self.model.ref, 'smith')
     self.assertTrue(expected_expression.compare(second_op.clauses[1]))
Beispiel #6
0
 def test_nested_bool_op(self):
     r = parse('firstname == "john" or (prog == 5 and lastname == "smith")',
               self.model)
     self.assertEqual(type(r), list)
     self.assertEqual(type(r[0]), BooleanClauseList)
     self.assertEqual(r[0].operator, or_)
     self.assertEqual(len(r[0].clauses), 2)
     expected_expression = sqla_op.eq(self.model.firstname, 'john')
     self.assertTrue(expected_expression.compare(r[0].clauses[0]))
     second_op = r[0].clauses[1]
     self.assertEqual(type(second_op), BooleanClauseList)
     self.assertEqual(second_op.operator, and_)
     self.assertEqual(len(second_op.clauses), 2)
     expected_expression = sqla_op.eq(self.model.prog, 5)
     self.assertTrue(expected_expression.compare(second_op.clauses[0]))
     expected_expression = sqla_op.eq(self.model.lastname, 'smith')
     self.assertTrue(expected_expression.compare(second_op.clauses[1]))
Beispiel #7
0
 def test_not_eq(self):
     expected_expression = sqla_op.ne(self.model.prog, 5)
     r = parse('prog != 5', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))
Beispiel #8
0
 def test_eq(self):
     expected_expression = sqla_op.eq(self.model.username, 'john')
     r = parse('username == john', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))
Beispiel #9
0
 def test_not_eq(self):
     expected_expression = sqla_op.ne(self.model.prog, 5)
     r = parse('prog != 5', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))
Beispiel #10
0
 def test_eq(self):
     expected_expression = sqla_op.eq(self.model.firstname, 'john')
     r = parse('firstname == john', self.model)
     self.assertEqual(type(r), list)
     self.assertTrue(len(r) == 1)
     self.assertTrue(expected_expression.compare(r[0]))