def test_has_contains(O): errors = [] setupGraph(O) count = 0 for i in O.query().V().has(gripql.contains("starships", "x-wing")): count += 1 if i['gid'] not in ["vertex2"]: errors.append("Wrong vertex returned %s" % (i)) if count != 1: errors.append( "Fail: O.query().V().has(gripql.contains(\"starships\", \"x-wing\")) %s != %s" % (count, 1)) return errors
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
def contains(self, *args, **kwargs): return gripql.contains(*args, **kwargs)