def test_traversal_definition_keys_are_valid(): muckefuck = Coffee(name="Mukkefuck", price=1) with raises(ValueError): Traversal( muckefuck, "a_name", { "node_class": Supplier, "direction": INCOMING, "relationship_type": "KNOWS", "model": None, }, ) Traversal( muckefuck, "a_name", { "node_class": Supplier, "direction": INCOMING, "relation_type": "KNOWS", "model": None, }, )
def listObjectsForPolicy(policyName): listRelatedNodes = list() policyObj = Policy.nodes.filter(name=policyName) if type(policyObj) is NodeSet: policyObj = policyObj.first_or_none() if policyObj: travDefn = dict(direction=EITHER, relation_type=None, model=None) trav = Traversal(policyObj, Policy.__label__, travDefn) listRelatedNodes.append(trav.all()) return listRelatedNodes
def listRelatedObjsFor(objName, objType): listRelatedNodes = list() obj = objType.nodes.filter(name=objName) if type(obj) is NodeSet: obj = obj.first_or_none() if obj: travDefn = dict(direction=EITHER, relation_type=None, model=None) trav = Traversal(obj, objType.__label__, travDefn) listRelatedNodes.append(trav.all()) return listRelatedNodes
def test_traversal_definition_keys_are_valid(): muckefuck = Coffee(name='Mukkefuck', price=1) with raises(ValueError): Traversal( muckefuck, 'a_name', { 'node_class': Supplier, 'direction': INCOMING, 'relationship_type': 'KNOWS', 'model': None }) Traversal( muckefuck, 'a_name', { 'node_class': Supplier, 'direction': INCOMING, 'relation_type': 'KNOWS', 'model': None })