示例#1
0
def test_compile_expression_nxor():
    func = compile_ast(
        parse({
            'nxor': [{
                'has': 'application'
            }, {
                'in': [('weight', ), [1, 2, 3]]
            }]
        }))
    assert not func(node_0)
    assert func(node_1)
    assert func(node_2)
示例#2
0
def test_compile_expression_lte_path():
    func = compile_ast(parse({'lte': [('_link', 'other', 'weight'), 2]}))
    assert func(node_2)
    func = compile_ast(parse({'lte': [('_link', 'other', 'weight'), 3]}))
    assert func(node_2)
示例#3
0
def test_compile_expression_gt_path():
    func = compile_ast(parse({'gt': [('_link', 'other', 'weight'), 1]}))
    assert func(node_2)
    func = compile_ast(parse({'gt': [('_link', 'other', 'weight'), 2]}))
    assert not func(node_2)
示例#4
0
def test_compile_expression_has_path():
    func = compile_ast(parse({'has': [('_link', 'other', 'weight')]}))
    assert not func(node_0)
    assert func(node_2)
示例#5
0
def test_compile_expression_has_dict():
    func = compile_ast(parse({'has': '_link'}))
    assert not func(node_0)
    assert func(node_2)
示例#6
0
def test_compile_expression_contains():
    func = compile_ast(parse({'contains': ['group', 'my']}))
    assert not func(node_0)
    assert func(node_1)
示例#7
0
def test_compile_expression_not_has():
    func = compile_ast(parse({'not': {'has': 'group'}}))
    assert func(node_0)
    assert not func(node_1)
示例#8
0
def test_compile_expression_has():
    func = compile_ast(parse({'has': 'application'}))
    assert func(node_0)
    assert func(node_1)
示例#9
0
def test_compile_expression_in_path():
    func = compile_ast(parse({'in': [('_link', 'other', 'weight'), [1, 2,
                                                                    3]]}))
    assert func(node_2)