コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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]}}
コード例 #4
0
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]}}
コード例 #5
0
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}}
コード例 #6
0
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]}}
コード例 #7
0
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]}}
コード例 #8
0
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}}