diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-10-23 06:25:43 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-10-23 06:25:43 +0000 |
| commit | 4875c3702c3d59072a3d074f4c3c384ebd6ffa9b (patch) | |
| tree | 07b3fcc777ce65a2ba0e02770c5fe9979a3a1a1c /test/dependency.py | |
| parent | 722f97a826944073089998c42c48371a2514b9d6 (diff) | |
| download | sqlalchemy-4875c3702c3d59072a3d074f4c3c384ebd6ffa9b.tar.gz | |
Diffstat (limited to 'test/dependency.py')
| -rw-r--r-- | test/dependency.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/dependency.py b/test/dependency.py new file mode 100644 index 000000000..7e04e7ec6 --- /dev/null +++ b/test/dependency.py @@ -0,0 +1,57 @@ +from testbase import PersistTest +import sqlalchemy.util as util +import unittest, sys, os + +class thingy(object): + def __init__(self, name): + self.name = name + def __repr__(self): + return "thingy(%d, %s)" % (id(self), self.name) + def __str__(self): + return repr(self) + +class DependencySortTest(PersistTest): + def testsort(self): + rootnode = thingy('root') + node2 = thingy('node2') + node3 = thingy('node3') + node4 = thingy('node4') + subnode1 = thingy('subnode1') + subnode2 = thingy('subnode2') + subnode3 = thingy('subnode3') + subnode4 = thingy('subnode4') + subsubnode1 = thingy('subsubnode1') + tuples = [ + (subnode3, subsubnode1), + (node2, subnode1), + (node2, subnode2), + (rootnode, node2), + (rootnode, node3), + (rootnode, node4), + (node4, subnode3), + (node4, subnode4) + ] + head = util.DependencySorter(tuples, []).sort() + print str(head) + + def testsort2(self): + node1 = thingy('node1') + node2 = thingy('node2') + node3 = thingy('node3') + node4 = thingy('node4') + node5 = thingy('node5') + node6 = thingy('node6') + node7 = thingy('node7') + tuples = [ + (node1, node2), + (node3, node4), + (node5, node6), + (node6, node2) + ] + head = util.DependencySorter(tuples, [node7]).sort() + print "\n" + str(head) + + + +if __name__ == "__main__": + unittest.main() |
