def test_full_node_hydrate(): dehydrated = { "extensions": { }, "paged_traverse": "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}", "labels": "http://localhost:7474/db/data/node/0/labels", "outgoing_relationships": "http://localhost:7474/db/data/node/0/relationships/out", "traverse": "http://localhost:7474/db/data/node/0/traverse/{returnType}", "all_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}", "property": "http://localhost:7474/db/data/node/0/properties/{key}", "all_relationships": "http://localhost:7474/db/data/node/0/relationships/all", "self": "http://localhost:7474/db/data/node/0", "outgoing_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}", "properties": "http://localhost:7474/db/data/node/0/properties", "incoming_relationships": "http://localhost:7474/db/data/node/0/relationships/in", "incoming_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}", "create_relationship": "http://localhost:7474/db/data/node/0/relationships", "data": { "name": "Alice", "age": 33, }, } hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert hydrated.properties == dehydrated["data"] assert hydrated.bound assert hydrated.resource.uri == dehydrated["self"]
def test_minimal_node_hydrate(self): dehydrated = { "self": "http://localhost:7474/db/data/node/0", } hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert remote(hydrated) assert remote(hydrated).uri == dehydrated["self"]
def test_minimal_node_hydrate(): dehydrated = { "self": "http://localhost:7474/db/data/node/0", } hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert hydrated.bound assert hydrated.resource.uri == dehydrated["self"]
def test_node_hydrate_with_properties(self): dehydrated = { "self": "http://localhost:7474/db/data/node/0", "data": { "name": "Alice", "age": 33, }, } hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert dict(hydrated) == dehydrated["data"] assert remote(hydrated) assert remote(hydrated).uri == dehydrated["self"]
def test_node_hydrate_with_properties(): dehydrated = { "self": "http://localhost:7474/db/data/node/0", "data": { "name": "Alice", "age": 33, }, } hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert hydrated.properties == dehydrated["data"] assert hydrated.bound assert hydrated.resource.uri == dehydrated["self"]
def test_node_hydration_with_issue_19542(self): dehydrated = { "extensions": {}, "paged_traverse": "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}", "labels": "http://localhost:7474/db/data/node/0/labels", "outgoing_relationships": "http://localhost:7474/db/data/node/0/relationships/out", "traverse": "http://localhost:7474/db/data/node/0/traverse/{returnType}", "all_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}", "property": "http://localhost:7474/db/data/node/0/properties/{key}", "all_relationships": "http://localhost:7474/db/data/node/0/relationships/all", "self": "http://localhost:7474/db/data/node/0", "outgoing_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}", "properties": "http://localhost:7474/db/data/node/0/properties", "incoming_relationships": "http://localhost:7474/db/data/node/0/relationships/in", "incoming_typed_relationships": "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}", "create_relationship": "http://localhost:7474/db/data/node/0/relationships", "data": { "name": "Alice", "age": 33, }, "metadata": { "labels": ["Person", "Employee"], }, } with patch("weakref.WeakValueDictionary.setdefault") as mocked: mocked.return_value = None hydrated = Node.hydrate(dehydrated) assert isinstance(hydrated, Node) assert dict(hydrated) == dehydrated["data"] assert set(hydrated.labels()) == set(dehydrated["metadata"]["labels"]) assert remote(hydrated) assert remote(hydrated).uri == dehydrated["self"]