def test_or(): q = Query(T, None) want = { '$or' : [{'i' : 3}, {'i' : 4}, {'i' : 5}] } assert q.filter((T.i == 3) | (T.i == 4) | (T.i == 5)).query == want assert Query(T, None).or_(T.i == 3, T.i == 4, T.i == 5).query == want
def test_nin(): q = Query(T, None) assert q.nin(T.i, 1, 2, 3).query == { 'i': { '$nin': [1, 2, 3] } }, q.nin(T.i, 1, 2, 3).query assert q.filter(T.i.nin(1, 2, 3)).query == {'i': {'$nin': [1, 2, 3]}}
def test_in(): q = Query(T, None) assert q.in_(T.i, 1, 2, 3).query == { 'i': { '$in': [1, 2, 3] } }, q.in_(T.i, 1, 2, 3).query assert q.filter(T.i.in_(1, 2, 3)).query == {'i': {'$in': [1, 2, 3]}}
def test_exists(): q = Query(T, None) assert q.filter(T.i.exists(False)).query == {'i': {'$exists': False}} assert q.filter(T.i.exists(True)).query == {'i': {'$exists': True}}
def test_nin(): q = Query(T, None) assert q.nin(T.i, 1, 2, 3).query == {'i' : {'$nin' : [1,2,3]}}, q.nin(T.i, 1, 2, 3).query assert q.filter(T.i.nin(1, 2, 3)).query == {'i' : {'$nin' : [1,2,3]}}
def test_in(): q = Query(T, None) assert q.in_(T.i, 1, 2, 3).query == {'i' : {'$in' : [1,2,3]}}, q.in_(T.i, 1, 2, 3).query assert q.filter(T.i.in_(1, 2, 3)).query == {'i' : {'$in' : [1,2,3]}}