コード例 #1
0
 def test_null_properties(self):
     stuff = Node(good=["puppies", "kittens"], bad=None)
     assert set(stuff.keys()) == {"good"}
     assert stuff.get("good") == ["puppies", "kittens"]
     assert stuff.get("bad") is None
     assert len(stuff) == 1
     assert stuff["good"] == ["puppies", "kittens"]
     assert stuff["bad"] is None
     assert "good" in stuff
     assert "bad" not in stuff
コード例 #2
0
 def test_can_create_node(self):
     alice = Node({"Person"}, {"name": "Alice", "age": 33})
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name", "age"}
     assert set(alice.values()) == {"Alice", 33}
     assert set(alice.items()) == {("name", "Alice"), ("age", 33)}
     assert alice.get("name") == "Alice"
     assert alice.get("age") == 33
     assert repr(alice)
     assert len(alice) == 2
     assert alice["name"] == "Alice"
     assert alice["age"] == 33
     assert "name" in alice
     assert "age" in alice
     assert set(iter(alice)) == {"name", "age"}