Beispiel #1
0
	def test_eval_op_condition(self):
		ob = ObjectsBackend()

		class Foo(object):
			a = 1

		assert ob.eval_op(EqualsCondition('a', 1), Foo())
		assert ob.eval_op(GreaterThanCondition('a', 0), Foo())
		assert ob.eval_op(GreaterThanOrEqualCondition('a', 1), Foo())
		assert ob.eval_op(LessThanCondition('a', 2), Foo())
		assert ob.eval_op(LessThanOrEqualCondition('a', 1), Foo())
Beispiel #2
0
	def test_eval_op_operator(self):
		ob = ObjectsBackend()

		class Foo(object):
			a = 1

		assert ob.eval_op(AndOperator(EqualsCondition('a', 1), GreaterThanCondition('a', 0)), Foo())
		assert ob.eval_op(OrOperator(EqualsCondition('a', 1), GreaterThanCondition('a', 0)), Foo())

		with pytest.raises(Exception):
			ob.eval_op(True, Foo())
Beispiel #3
0
    def test_eval_op_condition(self):
        ob = ObjectsBackend()

        class Foo(object):
            a = 1

        assert ob.eval_op(EqualsCondition('a', 1), Foo())
        assert ob.eval_op(GreaterThanCondition('a', 0), Foo())
        assert ob.eval_op(GreaterThanOrEqualCondition('a', 1), Foo())
        assert ob.eval_op(LessThanCondition('a', 2), Foo())
        assert ob.eval_op(LessThanOrEqualCondition('a', 1), Foo())
Beispiel #4
0
    def test_eval_op_operator(self):
        ob = ObjectsBackend()

        class Foo(object):
            a = 1

        assert ob.eval_op(
            AndOperator(EqualsCondition('a', 1), GreaterThanCondition('a', 0)),
            Foo())
        assert ob.eval_op(
            OrOperator(EqualsCondition('a', 1), GreaterThanCondition('a', 0)),
            Foo())

        with pytest.raises(Exception):
            ob.eval_op(True, Foo())
Beispiel #5
0
	def test_eval_op_groups(self):
		ob = ObjectsBackend()

		class Foo(object):
			a = 1
			b = 2

		assert ob.eval_op(ConditionGroup(
			OrOperator(EqualsCondition('a', 1), EqualsCondition('b', 2))
		), Foo())
Beispiel #6
0
    def test_eval_op_groups(self):
        ob = ObjectsBackend()

        class Foo(object):
            a = 1
            b = 2

        assert ob.eval_op(
            ConditionGroup(
                OrOperator(EqualsCondition('a', 1), EqualsCondition('b', 2))),
            Foo())