def test_topologicSort(self): depDict = {'2': ['11'], '9': ['11', '8'], '10': ['11', '3'], '11': ['7', '5'], '8': ['7' , '3'] } result = topologicSort(depDict) self.assertTrue(result, "no valid order is generated") result = topologicSort(depDict, '9') self.assertTrue(result, "no valid order is generated") print result result = topologicSort(depDict, '10') self.assertTrue(result, "no valid order is generated") print result result = topologicSort(depDict, '2') self.assertTrue(result, "no valid order is generated") print result self.assertTrue(result, "no valid order is generated") # this will create a cycle among 5, 11, 10 depDict.update({'5': ['10']}) self.assertRaises(Exception, topologicSort, depDict) # this will create a cycle among 2, 5, 8, 11 depDict.update({'5': ['8'], '8': ['7', '3', '2']}) self.assertRaises(Exception, topologicSort, depDict)
def test_topologicSort(self): depDict = {'2': ['11'], '9': ['11', '8'], '10': ['11', '3'], '11': ['7', '5'], '8': ['7', '3'], '12': [], } result = topologicSort(depDict) self.assertTrue(result, "no valid order is generated") self.assertTrue('12' in result, "orphan node is ignored") result = topologicSort(depDict, '9') self.assertTrue(result, "no valid order is generated") result = topologicSort(depDict, '10') self.assertTrue(result, "no valid order is generated") result = topologicSort(depDict, '2') self.assertTrue(result, "no valid order is generated") self.assertTrue(result, "no valid order is generated") # this will create a cycle among 5, 11, 10 depDict.update({'5': ['10']}) self.assertRaises(Exception, topologicSort, depDict) # this will create a cycle among 2, 5, 8, 11 depDict.update({'5': ['8'], '8': ['7', '3', '2']}) self.assertRaises(Exception, topologicSort, depDict)
def _topologicSort(self): from PatchOrderGenerator import topologicSort result = topologicSort(self._fileDep, '2') print result
def _topologicSort(self): from PatchOrderGenerator import topologicSort result = topologicSort(self._fileDep, '2')