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
def test_node_hashing(self): node_1 = Node() node_1.identity = "node/1234" node_2 = Node() node_2.identity = "node/1234" node_3 = Node() node_3.identity = "node/5678" assert hash(node_1) == hash(node_2) assert hash(node_1) != hash(node_3)
def test_node_equality(self): node_1 = Node() node_1.identity = "node/1234" node_2 = Node() node_2.identity = "node/1234" node_3 = Node() node_3.identity = "node/5678" assert node_1 == node_2 assert node_1 != node_3 assert node_1 != "this is not a node"
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"}