示例#1
0
文件: test_data.py 项目: SyBen/py2neo
 def test_setdefault_without_default_with_existing(self):
     properties = PropertyDict({"name": "Alice", "age": 33})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
示例#2
0
文件: test_data.py 项目: SyBen/py2neo
 def test_setdefault_without_default_with_non_existent(self):
     properties = PropertyDict({"name": "Alice"})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice"}
     assert value is None
示例#3
0
文件: test_data.py 项目: SyBen/py2neo
 def test_setter_with_none(self):
     properties = PropertyDict({"name": "Alice", "age": 33})
     properties["age"] = None
     assert properties == {"name": "Alice"}
示例#4
0
文件: test_data.py 项目: SyBen/py2neo
 def test_setter_with_none_for_non_existent(self):
     properties = PropertyDict({"name": "Alice"})
     properties["age"] = None
     assert properties == {"name": "Alice"}
示例#5
0
文件: test_data.py 项目: SyBen/py2neo
 def test_setter(self):
     properties = PropertyDict({"name": "Alice"})
     properties["age"] = 33
     assert properties == {"name": "Alice", "age": 33}
示例#6
0
文件: test_data.py 项目: SyBen/py2neo
 def test_getter_with_none(self):
     properties = PropertyDict({"name": "Alice"})
     assert properties["age"] is None
示例#7
0
文件: test_data.py 项目: SyBen/py2neo
 def test_getter(self):
     properties = PropertyDict({"name": "Alice"})
     assert properties["name"] == "Alice"
示例#8
0
 def relationship_entry(cls, entry):
     type_, nodes, properties = entry
     return RelationshipEntry(type_, tuple(nodes), PropertyDict(properties))
示例#9
0
    def node_entry(self, key, entry):

        def add_labels(*labels_):
            for label in labels_:
                self._nodes_by_label.setdefault(label, set()).add(key)

        def remove_labels(*labels_):
            for label in labels_:
                try:
                    self._nodes_by_label[label].discard(key)
                except KeyError:
                    pass

        labels, properties = entry
        return NodeEntry(ReactiveSet(labels, on_add=add_labels, on_remove=remove_labels), PropertyDict(properties))