def testGetPathsToCheck(testDefinition: TestDefinition): checker = NoIdentityOptimalSetPathChecker() checker.setGraph(testDefinition.test_graph) checker.setEdge(testDefinition.test_s, testDefinition.test_t) assertEqual(testDefinition.expected_solution_no_identity,\ checker.getPathsToCheck()) assert (checker.timeTaken > 0)
def testSigma(testDefinition: BatchTestDefinition): checker = BatchChecker() checker.setGraph(testDefinition.test_graph) if hasattr(testDefinition, 'sigma_test_subset'): result = checker.sigma(testDefinition.sigma_test_subset, testDefinition.all_pairs) assertEqual(testDefinition.expected_sigma, result)
def testMatrixify(testDefinition: Union[TestDefinition, BatchTestDefinition]): checker = BatchChecker() checker.setGraph(testDefinition.test_graph) if hasattr(testDefinition, 'pieces'): matrix = checker.matrixify(testDefinition.pieces, testDefinition.finalPair) assertEqual(testDefinition.expected_matrix, matrix)
def testVectorize(testDefinition: Union[TestDefinition, BatchTestDefinition]): checker = BatchChecker() checker.setGraph(testDefinition.test_graph) if hasattr(testDefinition, 'paths'): vectors = [checker.vectorize(v) for v in testDefinition.paths] for i in range(len(vectors)): assertEqual(testDefinition.expected_vectors[i], vectors[i])
def testSetEdge(testDefinition: TestDefinition): checker = NaiveChecker() checker.setGraph(testDefinition.test_graph) checker.setEdge(testDefinition.test_s, testDefinition.test_t) assertEqual(testDefinition.test_s, checker.newEdgeSource) assertEqual(testDefinition.test_t, checker.newEdgeSink) assertEqual(checker.graph[testDefinition.test_s][testDefinition.test_t], 1)
def testGetSinkCycles(testDefintion: TestDefinition): checker = NonIdentityPathChecker() checker.setGraph(testDefintion.test_graph) checker.setEdge(testDefintion.test_s, testDefintion.test_t) assertEqual(testDefintion.expected_sink_cycles,\ checker.getSinkCycles())
def testSetGraph(testDefinition: TestDefinition): checker = NaiveChecker() checker.setGraph(testDefinition.test_graph) assertEqual(checker.graph, testDefinition.test_graph)
def testGetPathsToCheck(testDefinition: TestDefinition): checker = BatchChecker() checker.setGraph(testDefinition.test_graph) if hasattr(testDefinition, 'expected_batch_result'): result = checker.getPathsToCheck() assertEqual(testDefinition.expected_batch_result, result)
def testFindCoTreePairs(testDefinition: BatchTestDefinition): checker = BatchChecker() checker.setGraph(testDefinition.test_graph) if hasattr(testDefinition, 'co_tree_root'): coTree = checker.findCoTreePairs(testDefinition.co_tree_root) assertEqual(testDefinition.expected_co_tree, coTree)
def testGetRootPairs(): checker = OptimalSetPathChecker() checker.setGraph(test_graph) checker.setEdge(test_s, test_t) assertEqual({(2, 2), (3, 3), (6, 6), (7, 7)}, checker.getRootPairs())
def testGetSuccessors(): checker = OptimalSetPathChecker() checker.setGraph(test_graph) assertEqual({(0, 4), (1, 4), (0, 5), (1, 5)}, checker.getSuccessors(1, 4))