def test_has_or(O): errors = [] setupGraph(O) count = 0 for i in O.query().V().has(gripql.or_(gripql.eq("occupation", "sith"), gripql.eq("occupation", "jedi"))): count += 1 if i['gid'] not in ["vertex2", "vertex5", "vertex6"]: errors.append("Wrong vertex returned %s" % (i)) if count != 3: errors.append( "Fail: O.query().V().has(gripql.or_(gripql.eq(\"occupation\", \"sith\"), gripql.eq(\"occupation\", \"jedi\"))) %s != %s" % (count, 3)) 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 or_(self, *args, **kwargs): return gripql.or_(*args, **kwargs)