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)
Пример #2
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)
Пример #3
0
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)
Пример #4
0
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])
Пример #5
0
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())
Пример #7
0
def testSetGraph(testDefinition: TestDefinition):
    checker = NaiveChecker()
    checker.setGraph(testDefinition.test_graph)
    assertEqual(checker.graph, testDefinition.test_graph)
Пример #8
0
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)
Пример #9
0
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)
Пример #10
0
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())
Пример #11
0
def testGetSuccessors():
    checker = OptimalSetPathChecker()
    checker.setGraph(test_graph)
    assertEqual({(0, 4), (1, 4), (0, 5), (1, 5)}, checker.getSuccessors(1, 4))