def test_filter_exclude_via_labels(): Coffee(name="Java", price=99).save() node_set = NodeSet(Coffee) qb = QueryBuilder(node_set).build_ast() results = qb._execute() assert "(coffee:Coffee)" in qb._ast["match"] assert "result_class" in qb._ast assert len(results) == 1 assert isinstance(results[0], Coffee) assert results[0].name == "Java" # with filter and exclude Coffee(name="Kenco", price=3).save() node_set = node_set.filter(price__gt=2).exclude(price__gt=6, name="Java") qb = QueryBuilder(node_set).build_ast() results = qb._execute() assert "(coffee:Coffee)" in qb._ast["match"] assert "NOT" in qb._ast["where"][0] assert len(results) == 1 assert results[0].name == "Kenco"
def test_filter_exclude_via_labels(): Coffee(name='Java', price=99).save() node_set = NodeSet(Coffee) qb = QueryBuilder(node_set).build_ast() results = qb._execute() assert '(coffee:Coffee)' in qb._ast['match'] assert 'result_class' in qb._ast assert len(results) == 1 assert isinstance(results[0], Coffee) assert results[0].name == 'Java' # with filter and exclude Coffee(name='Kenco', price=3).save() node_set = node_set.filter(price__gt=2).exclude(price__gt=6, name='Java') qb = QueryBuilder(node_set).build_ast() results = qb._execute() assert '(coffee:Coffee)' in qb._ast['match'] assert 'NOT' in qb._ast['where'][0] assert len(results) == 1 assert results[0].name == 'Kenco'