コード例 #1
0
 def test_can_hydrate_node_structure(self):
     struct = Structure(3, b"N")
     struct.append("node/123")
     struct.append(["Person"])
     struct.append({"name": "Alice"})
     alice = hydrated(struct)
     assert alice.identity == "node/123"
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name"}
     assert alice.get("name") == "Alice"
コード例 #2
0
 def test_can_hydrate_in_dict(self):
     struct = Structure(3, b"N")
     struct.append("node/123")
     struct.append(["Person"])
     struct.append({"name": "Alice"})
     alice_in_dict = hydrated({"foo": struct})
     assert isinstance(alice_in_dict, dict)
     alice = alice_in_dict["foo"]
     assert alice.identity == "node/123"
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name"}
     assert alice.get("name") == "Alice"
コード例 #3
0
 def test_can_hydrate_node_structure(self):
     struct = Structure(3, b'N')
     struct.append(123)
     struct.append(["Person"])
     struct.append({"name": "Alice"})
     alice = hydrated(struct)
     assert alice.id == 123
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name"}
     assert alice.get("name") == "Alice"
コード例 #4
0
 def test_can_hydrate_in_dict(self):
     struct = Structure(3, b'N')
     struct.append(123)
     struct.append(["Person"])
     struct.append({"name": "Alice"})
     alice_in_dict = hydrated({"foo": struct})
     assert isinstance(alice_in_dict, dict)
     alice = alice_in_dict["foo"]
     assert alice.id == 123
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name"}
     assert alice.get("name") == "Alice"
コード例 #5
0
 def test_can_hydrate_in_list(self):
     struct = Structure(3, b'N')
     struct.append(123)
     struct.append(["Person"])
     struct.append({"name": "Alice"})
     alice_in_list = hydrated([struct])
     assert isinstance(alice_in_list, list)
     alice, = alice_in_list
     assert alice.id == 123
     assert alice.labels == {"Person"}
     assert set(alice.keys()) == {"name"}
     assert alice.get("name") == "Alice"
コード例 #6
0
 def test_hydrating_unknown_structure_returns_same(self):
     struct = Structure(1, b'X')
     struct.append("foo")
     mystery = hydrated(struct)
     assert mystery == struct
コード例 #7
0
 def test_hydrating_unknown_structure_returns_same(self):
     struct = Structure(1, b"X")
     struct.append("foo")
     mystery = hydrated(struct)
     assert mystery == struct