Ejemplo n.º 1
0
 def test_full_relationship_hydrate(self):
     dehydrated = {
         "extensions": {},
         "start": "http://localhost:7474/db/data/node/23",
         "property":
         "http://localhost:7474/db/data/relationship/11/properties/{key}",
         "self": "http://localhost:7474/db/data/relationship/11",
         "properties":
         "http://localhost:7474/db/data/relationship/11/properties",
         "type": "KNOWS",
         "end": "http://localhost:7474/db/data/node/22",
         "data": {
             "since": 1999,
         },
     }
     hydrated = Relationship.hydrate(dehydrated)
     assert isinstance(hydrated, Relationship)
     assert remote(hydrated.start_node())
     assert remote(hydrated.start_node()).uri == dehydrated["start"]
     assert remote(hydrated.end_node())
     assert remote(hydrated.end_node()).uri == dehydrated["end"]
     assert hydrated.type() == dehydrated["type"]
     assert dict(hydrated) == dehydrated["data"]
     assert remote(hydrated)
     assert remote(hydrated).uri == dehydrated["self"]
Ejemplo n.º 2
0
 def test_relationship_hydration_with_issue_19542(self):
     dehydrated = {
         "extensions": {},
         "start": "http://localhost:7474/db/data/node/23",
         "property":
         "http://localhost:7474/db/data/relationship/11/properties/{key}",
         "self": "http://localhost:7474/db/data/relationship/11",
         "properties":
         "http://localhost:7474/db/data/relationship/11/properties",
         "type": "KNOWS",
         "end": "http://localhost:7474/db/data/node/22",
         "data": {
             "since": 1999,
         },
     }
     with patch("weakref.WeakValueDictionary.setdefault") as mocked:
         mocked.return_value = None
         hydrated = Relationship.hydrate(dehydrated)
     assert isinstance(hydrated, Relationship)
     assert remote(hydrated.start_node())
     assert remote(hydrated.start_node()).uri == dehydrated["start"]
     assert remote(hydrated.end_node())
     assert remote(hydrated.end_node()).uri == dehydrated["end"]
     assert hydrated.type() == dehydrated["type"]
     assert dict(hydrated) == dehydrated["data"]
     assert remote(hydrated)
     assert remote(hydrated).uri == dehydrated["self"]
Ejemplo n.º 3
0
 def test_partial_relationship_hydration_with_inst(self):
     a = Node()
     b = Node()
     ab = Relationship(a, "TO", b)
     self.graph.create(ab)
     dehydrated = {
         "extensions": {},
         "start":
         "http://localhost:7474/db/data/node/%d" % remote(a)._id,
         "property":
         "http://localhost:7474/db/data/relationship/%d/properties/{key}" %
         remote(ab)._id,
         "self":
         "http://localhost:7474/db/data/relationship/%d" % remote(ab)._id,
         "properties":
         "http://localhost:7474/db/data/relationship/%d/properties" %
         remote(ab)._id,
         "type":
         "KNOWS",
         "end":
         "http://localhost:7474/db/data/node/%d" % remote(b)._id,
     }
     hydrated = Relationship.hydrate(dehydrated, inst=ab)
     assert isinstance(hydrated, Relationship)
     assert remote(hydrated.start_node())
     assert remote(hydrated.start_node()).uri == dehydrated["start"]
     assert remote(hydrated.end_node())
     assert remote(hydrated.end_node()).uri == dehydrated["end"]
     assert hydrated.type() == dehydrated["type"]
     assert remote(hydrated)
     assert remote(hydrated).uri == dehydrated["self"]
Ejemplo n.º 4
0
def test_full_relationship_hydrate():
    dehydrated = {
        "extensions": {},
        "start": "http://localhost:7474/db/data/node/23",
        "property":
        "http://localhost:7474/db/data/relationship/11/properties/{key}",
        "self": "http://localhost:7474/db/data/relationship/11",
        "properties":
        "http://localhost:7474/db/data/relationship/11/properties",
        "type": "KNOWS",
        "end": "http://localhost:7474/db/data/node/22",
        "data": {
            "since": 1999,
        },
    }
    hydrated = Relationship.hydrate(dehydrated)
    assert isinstance(hydrated, Relationship)
    assert hydrated.type == dehydrated["type"]
    assert hydrated.properties == dehydrated["data"]
    assert hydrated.bound
    assert hydrated.resource.uri == dehydrated["self"]
Ejemplo n.º 5
0
def test_full_relationship_hydrate():
    dehydrated = {
        "extensions": {
        },
        "start": "http://localhost:7474/db/data/node/23",
        "property": "http://localhost:7474/db/data/relationship/11/properties/{key}",
        "self": "http://localhost:7474/db/data/relationship/11",
        "properties": "http://localhost:7474/db/data/relationship/11/properties",
        "type": "KNOWS",
        "end": "http://localhost:7474/db/data/node/22",
        "data": {
            "since": 1999,
        },
    }
    hydrated = Relationship.hydrate(dehydrated)
    assert isinstance(hydrated, Relationship)
    assert hydrated.type == dehydrated["type"]
    assert hydrated.properties == dehydrated["data"]
    assert hydrated.bound
    assert hydrated.resource.uri == dehydrated["self"]


# TODO: test hydration with supplied inst