# import Kratos
import KratosMultiphysics
import KratosMultiphysics.StructuralMechanicsApplication as StructuralMechanicsApplication
import KratosMultiphysics.CSharpWrapperApplication as CSharpWrapperApplication
import run_cpp_unit_tests

# Import Kratos "wrapper" for unittests
import KratosMultiphysics.KratosUnittest as KratosUnittest

# Import subprocess
import subprocess

# Using kratos_utilities
import KratosMultiphysics.kratos_utilities as kratos_utilities
if kratos_utilities.CheckIfApplicationsAvailable("ExternalSolversApplication"):
    has_external_solvers_application = True
else:
    has_external_solvers_application = False

# Import the tests o test_classes to create the suits
## SMALL TESTS

## NIGTHLY TESTS

## VALIDATION TESTS

def AssembleTestSuites():
    ''' Populates the test suites to run.

    Populates the test suites to run. At least, it should pupulate the suites:
    "small", "nighlty" and "all"

    Return
    ------

    suites: A dictionary of suites
        The set of suites with its test_cases added.
    '''
    suites = KratosUnittest.KratosSuites

    # Create a test suit with the selected tests (Small tests):
    smallSuite = suites['small']

    # Create a test suit with the selected tests plus all small tests
    nightlySuite = suites['nightly']

    ### BEGIN SMALL SUITE ###

    ### END SMALL SUITE ###

    ### BEGIN NIGHTLY SUITE ###

    ### END VALIDATION SUITE ###

    ### BEGIN VALIDATION SUITE ###

    # For very long tests that should not be in nighly and you can use to validate
    validationSuite = suites['validation']
    validationSuite.addTests(nightlySuite)

    ### END VALIDATION ###

    # Create a test suit that contains all the tests:
    allSuite = suites['all']
    allSuite.addTests(nightlySuite) # Already contains the smallSuite
    validationSuite.addTests(allSuite) # Validation contains all

    # Manual list for debugging
    #allSuite.addTests(
        #KratosUnittest.TestLoader().loadTestsFromTestCases([
            #### STANDALONE
            #### SMALL
            #### NIGTHLY
            #### VALIDATION
        #])
    #)

    return suites

if __name__ == '__main__':
    KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning cpp unit tests ...")
    run_cpp_unit_tests.run()
    KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished running cpp unit tests!")

    KratosMultiphysics.Logger.PrintInfo("Unittests", "\nRunning python tests ...")
    KratosUnittest.runTests(AssembleTestSuites())
    KratosMultiphysics.Logger.PrintInfo("Unittests", "Finished python tests!")

[((15, 3, 15, 78), 'KratosMultiphysics.kratos_utilities.CheckIfApplicationsAvailable', 'kratos_utilities.CheckIfApplicationsAvailable', ({(15, 49, 15, 77): '"""ExternalSolversApplication"""'}, {}), "('ExternalSolversApplication')", True, 'import KratosMultiphysics.kratos_utilities as kratos_utilities\n'), ((81, 4, 81, 84), 'KratosMultiphysics.Logger.PrintInfo', 'KratosMultiphysics.Logger.PrintInfo', ({(81, 40, 81, 51): '"""Unittests"""', (81, 53, 81, 83): '"""\nRunning cpp unit tests ..."""'}, {}), '(\'Unittests\',\n    """\nRunning cpp unit tests ...""")', False, 'import KratosMultiphysics\n'), ((82, 4, 82, 28), 'run_cpp_unit_tests.run', 'run_cpp_unit_tests.run', ({}, {}), '()', False, 'import run_cpp_unit_tests\n'), ((83, 4, 83, 88), 'KratosMultiphysics.Logger.PrintInfo', 'KratosMultiphysics.Logger.PrintInfo', ({(83, 40, 83, 51): '"""Unittests"""', (83, 53, 83, 87): '"""Finished running cpp unit tests!"""'}, {}), "('Unittests',\n    'Finished running cpp unit tests!')", False, 'import KratosMultiphysics\n'), ((85, 4, 85, 82), 'KratosMultiphysics.Logger.PrintInfo', 'KratosMultiphysics.Logger.PrintInfo', ({(85, 40, 85, 51): '"""Unittests"""', (85, 53, 85, 81): '"""\nRunning python tests ..."""'}, {}), '(\'Unittests\',\n    """\nRunning python tests ...""")', False, 'import KratosMultiphysics\n'), ((87, 4, 87, 78), 'KratosMultiphysics.Logger.PrintInfo', 'KratosMultiphysics.Logger.PrintInfo', ({(87, 40, 87, 51): '"""Unittests"""', (87, 53, 87, 77): '"""Finished python tests!"""'}, {}), "('Unittests', 'Finished python tests!')", False, 'import KratosMultiphysics\n')]