示例#1
0
def test_has_not(O):
    errors = []
    setupGraph(O)

    count = 0
    for i in O.query().V().has(gripql.not_(gripql.eq("_label", "person"))):
        count += 1
        if i['gid'] not in ["vertex3", "vertex4"]:
            errors.append("Wrong vertex returned %s" % (i))
    if count != 2:
        errors.append(
            "Fail: O.query().V().has(gripql.not_(gripql.eq(\"_label\", \"person\"))) %s != %s" %
            (count, 2))

    count = 0
    for i in O.query().V().has(gripql.not_(gripql.neq("_label", "person"))):
        count += 1
        if i['gid'] not in ["vertex1", "vertex2", "vertex5", "vertex6"]:
            errors.append("Wrong vertex returned %s" % (i))
    if count != 4:
        errors.append(
            "Fail: O.query().V().has(gripql.not_(gripql.neq(\"_label\", \"person\"))) %s != %s" %
            (count, 4))

    return errors
示例#2
0
def test_has_complex(O):
    errors = []
    setupGraph(O)

    count = 0
    for i in O.query().V().has(
            gripql.and_(
                gripql.eq("_label", "person"),
                gripql.not_(
                    gripql.or_(
                        gripql.eq("occupation", "jedi"),
                        gripql.eq("occupation", "sith")
                    )
                )
            )
    ):
        count += 1
        if i['gid'] != "vertex1":
            errors.append("Wrong vertex returned %s" % (i))
    if count != 1:
        errors.append(
            "Fail: O.query().V().has(gripql.and_(gripql.eq(\"_label\", \"person\"), gripql.not_(gripql.or_(gripql.eq(\"occupation\", \"jedi\"), gripql.eq(\"occupation\", \"sith\"))))) %s != %s" %
            (count, 1)
        )

    count = 0
    for i in O.query().V().has(
            gripql.not_(
                gripql.or_(
                    gripql.eq("_label", "robot"),
                    gripql.eq("occupation", "jedi"),
                )
            )
    ):
        count += 1
        if i['gid'] not in ["vertex1", "vertex6"]:
            errors.append("Wrong vertex returned %s" % (i))
    if count != 2:
        errors.append(
            "Fail: O.query().V().has(gripql.not_(gripql.and_(gripql.eq(\"_label\", \"robot\"), gripql.eq(\"occupation\", \"jedi\")))) %s != %s" %
            (count, 2)
        )

    count = 0
    for i in O.query().V().has(
            gripql.not_(
                gripql.or_(
                    gripql.eq("_label", "robot"),
                    gripql.or_(
                        gripql.eq("occupation", "jedi"),
                        gripql.contains("starships", "millennium falcon")
                    )
                )
            )
    ):
        count += 1
        if i['gid'] != "vertex6":
            errors.append("Wrong vertex returned %s" % (i))
    if count != 1:
        errors.append(
            "Fail: O.query().V().has(gripql.not_(gripql.or_(gripql.eq(\"_label\", \"robot\"), gripql.or_(gripql.eq(\"occupation\", \"jedi\"),  gripql.contains(\"starships\", \"millennium falcon\"))))) %s != %s" %
            (count, 1)
        )

    count = 0
    for i in O.query().V().has(
            gripql.not_(
                gripql.and_(
                    gripql.eq("_label", "robot"),
                    gripql.or_(
                        gripql.eq("occupation", "jedi"),
                        gripql.contains("starships", "millennium falcon")
                    )
                )
            )
    ):
        count += 1
    if count != 6:
        errors.append(
            "Fail: O.query().V().has(gripql.not_(gripql.and_(gripql.eq(\"_label\", \"robot\"), gripql.or_(gripql.eq(\"occupation\", \"jedi\"),  gripql.contains(\"starships\", \"millennium falcon\"))))) %s != %s" %
            (count, 6)
        )

    return errors
示例#3
0
 def not_(self, *args, **kwargs):
     return gripql.not_(*args, **kwargs)