当前位置: 首页>>代码示例>>Python>>正文


Python Node.bind方法代码示例

本文整理汇总了Python中py2neo.Node.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Node.bind方法的具体用法?Python Node.bind怎么用?Python Node.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py2neo.Node的用法示例。


在下文中一共展示了Node.bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_binding_node_if_labels_not_supported_casts_to_legacy_node

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_binding_node_if_labels_not_supported_casts_to_legacy_node():
    with patch("py2neo.Graph.supports_node_labels") as mocked:
        mocked.__get__ = Mock(return_value=False)
        alice = Node(name="Alice Smith")
        assert isinstance(alice, Node)
        alice.bind("http://localhost:7474/db/data/node/1")
        assert isinstance(alice, LegacyNode)
开发者ID:JohannesOos,项目名称:py2neo,代码行数:9,代码来源:node_test.py

示例2: test_bound_node_equality

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_bound_node_equality():
    alice_1 = Node(name="Alice")
    alice_1.bind("http://localhost:7474/db/data/node/1")
    Node.cache.clear()
    alice_2 = Node(name="Alice")
    alice_2.bind(alice_1.uri)
    assert alice_1 == alice_2
开发者ID:JohannesOos,项目名称:py2neo,代码行数:9,代码来源:node_test.py

示例3: test_can_pull_node

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_can_pull_node(graph):
    uri = graph.cypher.execute_one("CREATE (a {name:'Alice'}) RETURN a").uri
    alice = Node()
    alice.bind(uri)
    assert alice.properties["name"] is None
    batch = PullBatch(graph)
    batch.append(alice)
    batch.pull()
    assert alice.properties["name"] == "Alice"
开发者ID:EricEllett,项目名称:py2neo,代码行数:11,代码来源:pullbatch_test.py

示例4: test_rel_and_rev_hashes

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_rel_and_rev_hashes(graph):
    assert hash(Rel("KNOWS")) == hash(Rel("KNOWS"))
    assert hash(Rel("KNOWS")) == -hash(Rev("KNOWS"))
    assert hash(Rel("KNOWS", well=True, since=1999)) == hash(Rel("KNOWS", since=1999, well=True))
    rel_1 = Node("KNOWS", since=1999)
    graph.create(rel_1)
    rel_2 = Node("KNOWS", since=1999)
    rel_2.bind(rel_1.uri)
    assert rel_1 is not rel_2
    assert hash(rel_1) == hash(rel_2)
开发者ID:JohannesOos,项目名称:py2neo,代码行数:12,代码来源:hash_test.py

示例5: test_node_hashes

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_node_hashes(graph):
    assert hash(Node()) == hash(Node())
    assert hash(Node(name="Alice")) == hash(Node(name="Alice"))
    assert hash(Node(name="Alice", age=33)) == hash(Node(age=33, name="Alice"))
    assert hash(Node("Person", name="Alice", age=33)) == hash(Node("Person", age=33, name="Alice"))
    node_1 = Node("Person", name="Alice")
    graph.create(node_1)
    node_2 = Node("Person", name="Alice")
    node_2.bind(node_1.uri)
    assert node_1 is not node_2
    assert hash(node_1) == hash(node_2)
开发者ID:JohannesOos,项目名称:py2neo,代码行数:13,代码来源:hash_test.py

示例6: test_node_exists_will_raise_non_404_errors

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_node_exists_will_raise_non_404_errors():
    with patch.object(_Resource, "get") as mocked:
        error = GraphError("bad stuff happened")
        error.response = DodgyClientError()
        mocked.side_effect = error
        alice = Node(name="Alice Smith")
        alice.bind("http://localhost:7474/db/data/node/1")
        try:
            _ = alice.exists
        except GraphError:
            assert True
        else:
            assert False
开发者ID:JohannesOos,项目名称:py2neo,代码行数:15,代码来源:node_test.py

示例7: test_can_pull_node_with_label

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_can_pull_node_with_label(graph):
    if not graph.supports_node_labels:
        return
    uri = graph.cypher.execute_one("CREATE (a:Person {name:'Alice'}) RETURN a").uri
    alice = Node()
    alice.bind(uri)
    assert "Person" not in alice.labels
    assert alice.properties["name"] is None
    batch = PullBatch(graph)
    batch.append(alice)
    batch.pull()
    assert "Person" in alice.labels
    assert alice.properties["name"] == "Alice"
开发者ID:EricEllett,项目名称:py2neo,代码行数:15,代码来源:pullbatch_test.py

示例8: test_bound_node_equals_unbound_node_with_same_properties

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_bound_node_equals_unbound_node_with_same_properties():
    alice_1 = Node(name="Alice")
    alice_1.bind("http://localhost:7474/db/data/node/1")
    alice_2 = Node(name="Alice")
    assert alice_1 == alice_2
开发者ID:JohannesOos,项目名称:py2neo,代码行数:7,代码来源:node_test.py

示例9: test_can_join_similar_bound_nodes

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
def test_can_join_similar_bound_nodes():
    alice.bind("http://localhost:7474/db/data/node/1")
    Node.cache.clear()
    alice_2 = Node(name="Alice")
    alice_2.bind(alice.uri)
    assert Node.join(alice, alice_2) == alice
开发者ID:JohannesOos,项目名称:py2neo,代码行数:8,代码来源:node_join_test.py

示例10: Graph

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import bind [as 别名]
from __future__ import print_function
from py2neo import Graph, Node, Relationship

graph_db = Graph()

person = Node("Person", name="JUHASZ Lilla Linda")

for record in graph_db.cypher.execute("Match (n) return n"):
    print(record)

new_person = Node("Person", name="JUHASZ Peter", born=1930)
print("exists: " + str(list(graph_db.find("Person", property_key="name", property_value="JUHASZ Peter"))))

new_person.bind(graph_db.uri)
print("exists: " + str(new_person.exists))

father = graph_db.find_one("Person", property_key='name', property_value="JUHASZ Peter")

child = graph_db.find_one("Person", property_key='name', property_value="JUHASZ Lilla Linda")
child_of_rel = "CHILD_OF"
father_daughter_relationship = Relationship(child, child_of_rel, father)
graph_db.create(father_daughter_relationship)

开发者ID:sandordargo,项目名称:family-tree,代码行数:24,代码来源:read_from_db.py


注:本文中的py2neo.Node.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。