コード例 #1
0
ファイル: test_operand.py プロジェクト: Chubarkin/elysium
    def test_is_data(self):
        operand = Operand(TestModel.test_field_one)
        self.assertFalse(operand.is_data())

        operand = Operand(Condition(TestModel.test_field_one,
                                    TestModel.test_field_two, Operator('=')))
        self.assertFalse(operand.is_data())

        operand = Operand(EmptyOperand())
        self.assertFalse(operand.is_data())

        operand = Operand(1)
        self.assertTrue(operand.is_data())
コード例 #2
0
ファイル: test_operand.py プロジェクト: Chubarkin/elysium
    def test_to_str(self, field_to_str, condition_to_str):
        condition_to_str.return_value = 'test_condition'
        field_to_str.return_value = 'test_field'

        operand = Operand(Condition(TestModel.test_field_one,
                          TestModel.test_field_two, Operator('=')))
        self.assertEqual(operand.to_str(), 'test_condition')
        self.assertTrue(condition_to_str.called)

        operand = Operand(TestModel.test_field_one)
        self.assertEqual(operand.to_str(), 'test_field')
        self.assertTrue(field_to_str.called)

        operand = Operand(1)
        self.assertEqual(operand.to_str(), '%s')

        operand = Operand(None)
        self.assertEqual(operand.to_str(), '%s')

        operand = Operand(EmptyOperand())
        self.assertEqual(operand.to_str(), '')
コード例 #3
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test__validate(self, _operators):
     _operators.AND = Operator('TEST_AND')
     self.assertRaises(exceptions.ConditionError, self.condition._validate,
                       TestModelTwo.test_field_one,
                       TestModelTwo.test_field_two, _operators.AND)
コード例 #4
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def setUp(self):
     self.condition = Condition(TestModel.test_field_one,
                                TestModelTwo.test_field_two, Operator('='))
コード例 #5
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test_is_not_null(self):
     self.operators.IS_NULL = Operator('TEST_IS_NOT_NULL')
     condition = self.first_instance.is_not_null()
     self.assertIsInstance(condition, Condition)
     self.assertEqual(condition._operator, self.operators.IS_NOT_NULL)
コード例 #6
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test_in_(self):
     self.operators.IN = Operator('TEST_IN')
     condition = self.first_instance.in_([1, 2, 3])
     self.assertIsInstance(condition, Condition)
     self.assertEqual(condition._operator, self.operators.IN)
コード例 #7
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test_lt(self):
     self.operators.EQ = Operator('TEST_LT')
     condition = self.first_instance < self.second_instance
     self.assertIsInstance(condition, Condition)
     self.assertEqual(condition._operator, self.operators.LT)
コード例 #8
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test_ge(self):
     self.operators.EQ = Operator('TEST_GE')
     condition = self.first_instance >= self.second_instance
     self.assertIsInstance(condition, Condition)
     self.assertEqual(condition._operator, self.operators.GE)
コード例 #9
0
ファイル: test_condition.py プロジェクト: Chubarkin/elysium
 def test_or(self):
     self.operators.AND = Operator('TEST_OR')
     condition = self.first_instance | self.second_instance
     self.assertIsInstance(condition, Condition)
     self.assertEqual(condition._operator, self.operators.OR)
コード例 #10
0
ファイル: operators.py プロジェクト: Chubarkin/elysium
from elysium.query.operator import Operator

AND = Operator('AND')
OR = Operator('OR')
EQ = Operator('=')
NE = Operator('<>')
GE = Operator('>=')
GT = Operator('>')
LE = Operator('<=')
LT = Operator('<')
IN = Operator('IN')
IS_NULL = Operator('IS NULL')
IS_NOT_NULL = Operator('IS NOT NULL')