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