Example #1
0
def test_op_nor():
    assert match(data[0], {'$nor': [
        {'name': 'Li'},
        {'num': 2},
        {'info.attack': {'$eq': 102}},
    ]})
Example #2
0
def test_op_not():
    assert match(data[0], {'$not': 
                           {"name": "Li"}
    })
Example #3
0
def test_op_compare():
    assert match(data[0], {'info.attack': {'$gt': 99}})
    assert match(data[0], {'info.attack': {'$gte': 100}})
    assert match(data[0], {'info.attack': {'$lt': 101}})
    assert match(data[0], {'info.attack': {'$lte': 100}})
Example #4
0
def test_op_and():
    assert match(data[0], {'$and': [
        {'name': 'Wang'},
        {'num': 0},
        {'info.attack': {'$ne': 102}},
    ]})
Example #5
0
def test_op_in():
    assert match(data[0], {'name': {'$in': ['Wang', 'Zhao']}})
    assert match(data[0], {'tags': {'$in': ['sun']}})
    assert match(data[0], {'tags': {'$in': [['sun', 'moon']]}})
Example #6
0
def test_op_nin():
    assert match(data[0], {'name': {'$nin': ['Li', 'Qian']}})
    assert match(data[0], {'tags': {'$nin': ['saturn']}})
    assert match(data[0], {'tags': {'$nin': [['saturn', 'ceras']]}})
Example #7
0
def test_op_eq():
    assert match(data[0], {'info.attack': {'$eq': 100}})
    assert match(data[0], {'tags': {'$eq': "sun"}})
    assert match(data[0], {'tags': {'$eq': ["sun", "moon"]}})
Example #8
0
def test_op_ne():
    assert match(data[0], {'info.attack': {'$ne': 101}})
    assert match(data[0], {'tags': {'$ne': "fogs"}})
Example #9
0
def test_simple_separated_equal():
    assert match(data[0], {'info.attack': 100})
Example #10
0
def test_simple_separated_inequal():
    assert not match(data[0], {'info.attack': 50})
Example #11
0
def test_simple_nested_inequal():
    assert not match(data[0], {'info': {'attack': 50}})
Example #12
0
def test_simple_nested_equal():
    assert match(data[0], {'info': {'attack': 100}})
Example #13
0
def test_simple_int_inequal():
    assert not match(data[0], {'num': 1})
Example #14
0
def test_simple_int_equal():
    assert match(data[0], {'num': 0})
Example #15
0
def test_exists():
    assert match(data[0], {'num': {'$exists': True}})
    assert match(data[0], {'non': {'$exists': False}})