コード例 #1
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_set_properties_on_preexisting_node(graph):
    alice, = graph.create({})
    batch = WriteBatch(graph)
    batch.set_properties(alice, {"name": "Alice", "age": 34})
    batch.run()
    assert alice["name"] == "Alice"
    assert alice["age"] == 34
コード例 #2
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_delete_properties_on_preexisting_node(graph):
    alice, = graph.create({"name": "Alice", "age": 34})
    batch = WriteBatch(graph)
    batch.delete_properties(alice)
    batch.run()
    props = alice.get_properties()
    assert props == {}
コード例 #3
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_delete_property_on_preexisting_node(graph):
    alice, = graph.create({"name": "Alice", "age": 34})
    batch = WriteBatch(graph)
    batch.delete_property(alice, "age")
    batch.run()
    assert alice["name"] == "Alice"
    assert alice["age"] is None
コード例 #4
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_cannot_create_with_bad_type(graph):
    batch = WriteBatch(graph)
    try:
        batch.create("this is not creatable")
    except TypeError:
        assert True
    else:
        assert False
コード例 #5
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_add_labels_to_preexisting_node(graph):
    if not graph.supports_node_labels:
        return
    alice, = graph.create({"name": "Alice"})
    batch = WriteBatch(graph)
    batch.add_labels(alice, "human", "female")
    batch.run()
    assert alice.get_labels() == {"human", "female"}
コード例 #6
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_cannot_create_with_bad_type(graph):
    batch = WriteBatch(graph)
    try:
        batch.create("this is not creatable")
    except TypeError:
        assert True
    else:
        assert False
コード例 #7
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_create_path_with_new_nodes(graph):
    batch = WriteBatch(graph)
    batch.create_path({"name": "Alice"}, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    assert len(path) == 1
    assert path.nodes[0]["name"] == "Alice"
    assert path.relationships[0].type == "KNOWS"
    assert path.nodes[1]["name"] == "Bob"
コード例 #8
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_create_path_with_new_nodes(graph):
    batch = WriteBatch(graph)
    batch.create_path({"name": "Alice"}, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    assert len(path) == 1
    assert path.nodes[0]["name"] == "Alice"
    assert path.relationships[0].type == "KNOWS"
    assert path.nodes[1]["name"] == "Bob"
コード例 #9
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_set_labels_on_preexisting_node(graph):
    if not graph.supports_node_labels:
        return
    alice, = graph.create({"name": "Alice"})
    alice.add_labels("human", "female")
    batch = WriteBatch(graph)
    batch.set_labels(alice, "mystery", "badger")
    batch.run()
    assert alice.get_labels() == {"mystery", "badger"}
コード例 #10
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_get_or_create_path_with_existing_nodes(graph):
    alice, bob = graph.create({"name": "Alice"}, {"name": "Bob"})
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", bob)
    results = batch.submit()
    path = results[0]
    assert len(path) == 1
    assert path.nodes[0] == alice
    assert path.relationships[0].type == "KNOWS"
    assert path.nodes[1] == bob
コード例 #11
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_get_or_create_path_with_existing_nodes(graph):
    alice, bob = graph.create({"name": "Alice"}, {"name": "Bob"})
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", bob)
    results = batch.submit()
    path = results[0]
    assert len(path) == 1
    assert path.nodes[0] == alice
    assert path.relationships[0].type == "KNOWS"
    assert path.nodes[1] == bob
コード例 #12
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_set_labels_on_node_in_same_batch(graph):
    if not graph.supports_node_labels:
        return
    batch = WriteBatch(graph)
    batch.create({"name": "Alice"})
    batch.add_labels(0, "human", "female")
    batch.set_labels(0, "mystery", "badger")
    results = batch.submit()
    alice = results[0]
    assert alice.labels == {"mystery", "badger"}
コード例 #13
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_add_and_remove_labels_on_node_in_same_batch(graph):
    if not graph.supports_node_labels:
        return
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice"})
    batch.add_labels(alice, "human", "female")
    batch.remove_label(alice, "female")
    results = batch.submit()
    alice = results[batch.find(alice)]
    assert alice.labels == {"human"}
コード例 #14
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_path_merging_is_idempotent(graph):
    alice, = graph.create({"name": "Alice"})
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    bob = path.nodes[1]
    assert path.nodes[0] == alice
    assert bob["name"] == "Bob"
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    assert path.nodes[0] == alice
    assert path.nodes[1] == bob
コード例 #15
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_add_labels_to_node_in_same_batch(graph):
    if not graph.supports_node_labels:
        return
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice"})
    batch.add_labels(alice, "human", "female")
    batch.remove_label(alice, "female")
    results = batch.submit()
    alice = results[batch.find(alice)]
    assert alice.get_labels() == {"human"}
コード例 #16
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_set_labels_on_node_in_same_batch(graph):
    if not graph.supports_node_labels:
        return
    batch = WriteBatch(graph)
    batch.create({"name": "Alice"})
    batch.add_labels(0, "human", "female")
    batch.set_labels(0, "mystery", "badger")
    results = batch.submit()
    alice = results[0]
    assert alice.get_labels() == {"mystery", "badger"}
コード例 #17
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_set_property_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice"})
    batch.set_property(alice, "age", 34)
    results = batch.submit()
    alice = results[batch.find(alice)]
    alice.auto_sync_properties = True
    assert alice["age"] == 34
コード例 #18
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_delete_properties_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice", "age": 34})
    batch.delete_properties(alice)
    results = batch.submit()
    alice = results[batch.find(alice)]
    alice.pull()
    assert alice.properties == {}
コード例 #19
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_delete_property_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice", "age": 34})
    batch.delete_property(alice, "age")
    results = batch.submit()
    alice = results[batch.find(alice)]
    alice.auto_sync_properties = True
    assert alice["name"] == "Alice"
    assert alice["age"] is None
コード例 #20
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_set_property_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice"})
    batch.set_property(alice, "age", 34)
    results = batch.submit()
    alice = results[batch.find(alice)]
    assert alice["age"] == 34
コード例 #21
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_delete_properties_on_preexisting_node(graph):
    alice, = graph.create({"name": "Alice", "age": 34})
    batch = WriteBatch(graph)
    batch.delete_properties(alice)
    batch.run()
    alice.pull()
    assert alice.properties == {}
コード例 #22
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_set_property_on_preexisting_node(graph):
    alice, = graph.create({"name": "Alice"})
    batch = WriteBatch(graph)
    batch.set_property(alice, "age", 34)
    batch.run()
    alice.pull()
    assert alice["age"] == 34
コード例 #23
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_set_properties_on_preexisting_node(graph):
    alice, = graph.create({})
    batch = WriteBatch(graph)
    batch.set_properties(alice, {"name": "Alice", "age": 34})
    batch.run()
    alice.pull()
    assert alice["name"] == "Alice"
    assert alice["age"] == 34
コード例 #24
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_path_merging_is_idempotent(graph):
    alice, = graph.create({"name": "Alice"})
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    bob = path.nodes[1]
    assert path.nodes[0] == alice
    assert bob["name"] == "Bob"
    batch = WriteBatch(graph)
    batch.get_or_create_path(alice, "KNOWS", {"name": "Bob"})
    results = batch.submit()
    path = results[0]
    assert path.nodes[0] == alice
    assert path.nodes[1] == bob
コード例 #25
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_delete_property_on_preexisting_node(graph):
    alice, = graph.create({"name": "Alice", "age": 34})
    batch = WriteBatch(graph)
    batch.delete_property(alice, "age")
    batch.run()
    alice.pull()
    assert alice["name"] == "Alice"
    assert alice["age"] is None
コード例 #26
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_delete_property_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice", "age": 34})
    batch.delete_property(alice, "age")
    results = batch.submit()
    alice = results[batch.find(alice)]
    assert alice["name"] == "Alice"
    assert alice["age"] is None
コード例 #27
0
ファイル: writebatch_test.py プロジェクト: EricEllett/py2neo
def test_can_delete_properties_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({"name": "Alice", "age": 34})
    batch.delete_properties(alice)
    results = batch.submit()
    alice = results[batch.find(alice)]
    props = alice.get_properties()
    assert props == {}
コード例 #28
0
ファイル: writebatch_test.py プロジェクト: JohannesOos/py2neo
def test_can_set_properties_on_node_in_same_batch(graph):
    batch = WriteBatch(graph)
    alice = batch.create({})
    batch.set_properties(alice, {"name": "Alice", "age": 34})
    results = batch.submit()
    alice = results[batch.find(alice)]
    alice.auto_sync_properties = True
    assert alice["name"] == "Alice"
    assert alice["age"] == 34
コード例 #29
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_add_labels_to_preexisting_node(graph):
    if not graph.supports_node_labels:
        return
    alice, = graph.create({"name": "Alice"})
    batch = WriteBatch(graph)
    batch.add_labels(alice, "human", "female")
    batch.run()
    alice.pull()
    assert alice.labels == {"human", "female"}
コード例 #30
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_remove_labels_from_preexisting_node(graph):
    if not graph.supports_node_labels:
        return
    alice, = graph.create(Node("human", "female", name="Alice"))
    batch = WriteBatch(graph)
    batch.remove_label(alice, "human")
    batch.run()
    alice.pull()
    assert alice.labels == {"female"}
コード例 #31
0
ファイル: writebatch_test.py プロジェクト: zrg1993/py2neo
def test_can_set_labels_on_preexisting_node(graph):
    if not graph.supports_node_labels:
        return
    alice, = graph.create(Node("human", "female", name="Alice"))
    batch = WriteBatch(graph)
    batch.set_labels(alice, "mystery", "badger")
    batch.run()
    alice.pull()
    assert alice.labels == {"mystery", "badger"}