def test_complicated(self, less_than, greater_than): first = q.Q("a", q.Q("b", q.And(q.Q("c", less_than), greater_than))) second = q.Q("a", q.Q("b", q.Q("c", greater_than))) combined = q.Q( "a", q.Q("b", q.And(q.Q("c", q.And(less_than, greater_than)), greater_than))) assert first & second == combined
def test_and(aggregator): construction = ((aggregator.centre == mock.Gaussian) & (aggregator.centre.x == 0)) assert construction == q.Q( "centre", q.And( q.T(mock.Gaussian), q.Q( "x", q.V( "=", 0 ) ) ) )
def test_single_argument(): assert isinstance(q.And(q.Q("a")), q.Q)
def test_and_commutativity(): a_and_b = q.And(q.Q("a"), q.Q("b")) combined = a_and_b & q.Q("c") assert combined == q.And(q.Q("a"), q.Q("b"), q.Q("c")) assert len(combined.conditions) == 3
def test_and(aggregator): construction = ((aggregator.model.centre == af.Gaussian) & (aggregator.model.centre.x == 0)) assert construction.query == q.Q( "centre", q.And(q.T(af.Gaussian), q.Q("x", q.V("=", 0)))).query
def make_second_level(less_than, greater_than): return q.Q("a", q.And(less_than, q.Q('b', greater_than)))
def make_simple_and(less_than, greater_than): return q.Q("a", q.And(less_than, greater_than))