コード例 #1
0
ファイル: test_ogm.py プロジェクト: SyBen/py2neo
    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)
コード例 #2
0
ファイル: test_ogm_movies.py プロジェクト: timgates42/py2neo
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
コード例 #3
0
ファイル: test_ogm_movies.py プロジェクト: timgates42/py2neo
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"
コード例 #4
0
ファイル: test_ogm_movies.py プロジェクト: timgates42/py2neo
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
コード例 #5
0
ファイル: test_ogm.py プロジェクト: SyBen/py2neo
    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)
コード例 #6
0
    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"
コード例 #7
0
    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
コード例 #8
0
ファイル: test_ogm.py プロジェクト: SyBen/py2neo
    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")
コード例 #9
0
ファイル: test_ogm_movies.py プロジェクト: timgates42/py2neo
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"
コード例 #10
0
ファイル: test_ogm_movies.py プロジェクト: timgates42/py2neo
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"
コード例 #11
0
    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"
コード例 #12
0
    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"
コード例 #13
0
ファイル: test_ogm.py プロジェクト: SyBen/py2neo
    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")
コード例 #14
0
ファイル: test_ogm.py プロジェクト: SyBen/py2neo
    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")