def test(self): n0, n1, n2, n3 = Node(), Node(), Node(), Node() n0.relate([n1, n2, n3], 'CONTAINS') n0.relate([n1, n2], 'RELATED') # Get all relationships from n0 rels = n0.rels() nodes = rels.nodes() # Gets distinct set of end nodes of rels self.assertCountEqual(nodes, [n1, n2, n3])
def test_rels(self): s = Node() e = Node() o = Node() r0 = s.relate(e, 'R') r1 = s.relate(e, 'A', direction=-1) r2 = s.relate(o, 'R') self.assertCountEqual(s.rels(e), [r0, r1]) self.assertCountEqual(s.rels(e, direction=1), [r0]) self.assertCountEqual(s.rels(e, direction=-1), [r1]) self.assertCountEqual(s.rels(type='R'), [r0, r2]) self.assertCountEqual(s.rels(type='R', direction=1), [r0, r2]) self.assertCountEqual(s.rels(type='A', direction=-1), [r1]) self.assertCountEqual(s.rels(e, type='R'), [r0]) self.assertCountEqual(s.rels(e, type='R', direction=1), [r0]) self.assertCountEqual(s.rels(e, type='A', direction=-1), [r1]) self.assertCountEqual(s.rels(), [r0, r1, r2]) self.assertCountEqual(s.rels(direction=1), [r0, r2]) self.assertCountEqual(s.rels(direction=-1), [r1])