def test_linking_two_vertexes(self): with self.driver.session("smoke/test_make") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) self.assertEqual([["path", [["foobar", b_guid]]]], session.execute_fetch("path %s -[foobar]> ()" % (a_guid, )))
def test_path_without_arguments(self): with self.driver.session("smoke/test_path") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) helpers.link(session, a_guid, "foobaz", b_guid) answer0 = session.execute_fetch("path %s -[*]> ()" % (a_guid,)) answer1 = session.execute_fetch("path %s" % (a_guid,)) self.assertEqual(answer0, answer1)
def test_path_without_arguments(self): with self.driver.session("smoke/test_path") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) helpers.link(session, a_guid, "foobaz", b_guid) answer0 = session.execute_fetch("path %s -[*]> ()" % (a_guid, )) answer1 = session.execute_fetch("path %s" % (a_guid, )) self.assertEqual(answer0, answer1)
def test_kill_with_right_node(self): with self.driver.session("smoke/test_kill") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) helpers.link(session, a_guid, "foobar", c_guid) self.assertEqual(2, session.execute_fmap(len, "path %s -[foobar]> ()" % (a_guid,))) helpers.kill(session, a_guid, "foobar", b_guid) self.assertEqual([["path", [["foobar", c_guid]]]], session.execute_fetch("path %s -[foobar]> ()" % (a_guid,)))
def test_kill_without_right_node(self): with self.driver.session("smoke/test_kill") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "b", b_guid) helpers.link(session, a_guid, "c", c_guid) self.assertEqual( 2, session.execute_fmap(len, "path %s -[*]> ()" % (a_guid, ))) helpers.kill(session, a_guid, "b") self.assertEqual([["path", [["c", c_guid]]]], session.execute_fetch("path %s -[*]> ()" % (a_guid, )))
def test_path_using_prefix(self): with self.driver.session("smoke/test_path") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) helpers.link(session, a_guid, "foobaz", c_guid) answer = session.execute_fetch("path %s -[foo*]> ()" % (a_guid,)) if (answer[0][1][0][-1] == b_guid): self.assertEqual([["path",[["foobar", b_guid]]], ["path",[["foobaz", c_guid]]]], answer) else: self.assertEqual([["path",[["foobaz", c_guid]]], ["path",[["foobar", b_guid]]]], answer)
def test_path_using_prefix(self): with self.driver.session("smoke/test_path") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) helpers.link(session, a_guid, "foobaz", c_guid) answer = session.execute_fetch("path %s -[foo*]> ()" % (a_guid, )) if (answer[0][1][0][-1] == b_guid): self.assertEqual([["path", [["foobar", b_guid]]], ["path", [["foobaz", c_guid]]]], answer) else: self.assertEqual([["path", [["foobaz", c_guid]]], ["path", [["foobar", b_guid]]]], answer)
def test_path_with_restriction(self): with self.driver.session("smoke/test_path") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) c_guid = helpers.make(session) d_guid = helpers.make(session) helpers.link(session, a_guid, "a", b_guid) helpers.link(session, a_guid, "a", c_guid) helpers.link(session, b_guid, "x", d_guid) helpers.link(session, c_guid, "x", d_guid) answer0 = session.execute_fetch("path %s -[a]> %s -[x]> ()" % (a_guid, b_guid)) answer1 = session.execute_fetch("path %s -[a]> %s -[x]> ()" % (a_guid, c_guid)) self.assertEqual([["path", [["a", b_guid], ["x", d_guid]]]], answer0) self.assertEqual([["path", [["a", c_guid], ["x", d_guid]]]], answer1)
def test_linking_two_vertexes(self): with self.driver.session("smoke/test_make") as session: a_guid = helpers.make(session) b_guid = helpers.make(session) helpers.link(session, a_guid, "foobar", b_guid) self.assertEqual([["path", [["foobar", b_guid]]]], session.execute_fetch("path %s -[foobar]> ()" % (a_guid,)))