Beispiel #1
0
def test_op_nor():
    assert match(data[0], {'$nor': [
        {'name': 'Li'},
        {'num': 2},
        {'info.attack': {'$eq': 102}},
    ]})
Beispiel #2
0
def test_op_not():
    assert match(data[0], {'$not': 
                           {"name": "Li"}
    })
Beispiel #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}})
Beispiel #4
0
def test_op_and():
    assert match(data[0], {'$and': [
        {'name': 'Wang'},
        {'num': 0},
        {'info.attack': {'$ne': 102}},
    ]})
Beispiel #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']]}})
Beispiel #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']]}})
Beispiel #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"]}})
Beispiel #8
0
def test_op_ne():
    assert match(data[0], {'info.attack': {'$ne': 101}})
    assert match(data[0], {'tags': {'$ne': "fogs"}})
Beispiel #9
0
def test_simple_separated_equal():
    assert match(data[0], {'info.attack': 100})
Beispiel #10
0
def test_simple_separated_inequal():
    assert not match(data[0], {'info.attack': 50})
Beispiel #11
0
def test_simple_nested_inequal():
    assert not match(data[0], {'info': {'attack': 50}})
Beispiel #12
0
def test_simple_nested_equal():
    assert match(data[0], {'info': {'attack': 100}})
Beispiel #13
0
def test_simple_int_inequal():
    assert not match(data[0], {'num': 1})
Beispiel #14
0
def test_simple_int_equal():
    assert match(data[0], {'num': 0})
Beispiel #15
0
def test_exists():
    assert match(data[0], {'num': {'$exists': True}})
    assert match(data[0], {'non': {'$exists': False}})