def test_not_exists_on_non_existing(self): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 # when exists = self.graph.exists(alice) # then self.assertFalse(exists)
def test_not_exists_on_non_existing(movie_repo): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 # when exists = movie_repo.exists(alice) # then assert not exists
def test_can_push_new(movie_repo): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 # when movie_repo.save(alice) # then node_id = alice.__node__.identity remote_name = movie_repo.graph.evaluate("MATCH (a:Person) WHERE id(a) = $x " "RETURN a.name", x=node_id) assert remote_name == "Alice Smith"
def test_create(movie_repo): # given alice = Person() alice.name = "Alice" alice.year_of_birth = 1970 alice.acted_in.add(Film.match(movie_repo, "The Matrix").first()) # when movie_repo.save(alice) # then node = alice.__node__ assert node.graph == movie_repo.graph assert node.identity is not None
def test_create(self): # given alice = Person() alice.name = "Alice" alice.year_of_birth = 1970 alice.acted_in.add(Film.match(self.graph, "The Matrix").first()) # when self.graph.create(alice) # then node = alice.__node__ self.assertEqual(node.graph, self.graph) self.assertIsNotNone(node.identity)
def test_can_push_new(self): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 # when self.graph.push(alice) # then remote_node = remote(alice.__ogm__.node) remote_name = self.graph.evaluate("MATCH (a:Person) WHERE id(a) = {x} " "RETURN a.name", x=remote_node._id) assert remote_name == "Alice Smith"
def test_create(self): # given alice = Person() alice.name = "Alice" alice.year_of_birth = 1970 alice.acted_in.add(Film.select(self.graph, "The Matrix").first()) # when self.graph.create(alice) # then node = alice.__ogm__.node remote_node = remote(node) assert remote_node
def test_can_push_new(self): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 # when self.graph.push(alice) # then node_id = alice.__node__.identity remote_name = self.graph.evaluate( "MATCH (a:Person) WHERE id(a) = {x} " "RETURN a.name", x=node_id) self.assertEqual(remote_name, "Alice Smith")
def test_can_push_new_that_points_to_new(movie_repo): # given the_dominatrix = Film("The Dominatrix") alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(the_dominatrix) # when movie_repo.save(alice) # then node_id = alice.__node__.identity film_node = movie_repo.graph.evaluate("MATCH (a:Person)-[:ACTED_IN]->(b) " "WHERE id(a) = $x RETURN b", x=node_id) assert film_node["title"] == "The Dominatrix"
def test_can_push_new_that_points_to_existing(movie_repo): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(Film.match(movie_repo, "The Matrix").first()) # when movie_repo.save(alice) # then node_id = alice.__node__.identity film_node = movie_repo.graph.evaluate("MATCH (a:Person)-[:ACTED_IN]->(b) " "WHERE id(a) = $x RETURN b", x=node_id) assert film_node["title"] == "The Matrix" assert film_node["tagline"] == "Welcome to the Real World"
def test_can_push_new_that_points_to_new(self): # given the_dominatrix = Film("The Dominatrix") alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(the_dominatrix) # when self.graph.push(alice) # then remote_node = remote(alice.__ogm__.node) film_node = self.graph.evaluate("MATCH (a:Person)-[:ACTED_IN]->(b) WHERE id(a) = {x} RETURN b", x=remote_node._id) assert film_node["title"] == "The Dominatrix"
def test_can_push_new_that_points_to_existing(self): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(Film.select(self.graph, "The Matrix").first()) # when self.graph.push(alice) # then remote_node = remote(alice.__ogm__.node) film_node = self.graph.evaluate("MATCH (a:Person)-[:ACTED_IN]->(b) WHERE id(a) = {x} RETURN b", x=remote_node._id) assert film_node["title"] == "The Matrix" assert film_node["tagline"] == "Welcome to the Real World"
def test_can_push_new_that_points_to_new(self): # given the_dominatrix = Film("The Dominatrix") alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(the_dominatrix) # when self.graph.push(alice) # then node_id = alice.__node__.identity film_node = self.graph.evaluate( "MATCH (a:Person)-[:ACTED_IN]->(b) WHERE id(a) = {x} RETURN b", x=node_id) self.assertEqual(film_node["title"], "The Dominatrix")
def test_can_push_new_that_points_to_existing(self): # given alice = Person() alice.name = "Alice Smith" alice.year_of_birth = 1970 alice.acted_in.add(Film.match(self.graph, "The Matrix").first()) # when self.graph.push(alice) # then node_id = alice.__node__.identity film_node = self.graph.evaluate( "MATCH (a:Person)-[:ACTED_IN]->(b) WHERE id(a) = {x} RETURN b", x=node_id) self.assertEqual(film_node["title"], "The Matrix") self.assertEqual(film_node["tagline"], "Welcome to the Real World")