# Path: pyDEA/core/utils/dea_utils.py
# def clean_up_pickled_files():
#     ''' Removes mps-files from current folder and p-files from temporary folder.
#     '''
#     if os.path.exists(TMP_FOLDER):
#         filelist = [f for f in os.listdir(TMP_FOLDER) if f.endswith('.p')]
#         for f in filelist:
#             os.remove(os.path.join(TMP_FOLDER, f))
#     # remove mps file if any
#     filelist = [f for f in os.listdir('.') if f.endswith('.mps')]
#     for f in filelist:
#         os.remove(f)


from pulp import LpStatusOptimal
from pyDEA.core.data_processing.read_data_from_xls import read_data
from pyDEA.core.data_processing.read_data_from_xls import construct_input_data_instance
from pyDEA.core.data_processing.read_data_from_xls import validate_data
from pyDEA.core.data_processing.read_data_from_xls import convert_to_dictionary
from pyDEA.core.utils.dea_utils import clean_up_pickled_files
import pytest



EQ_TOLERANCE = 1e-10
WEIGHT_RESTRICTION_TOLERANCE = 1e-7


@pytest.fixture
def DEA_example2_data(request):
    categories, xls_data, dmu_name, sheet_name = read_data(
        'tests/DEA_example2_data.xls')
    coefficients, has_same_dmus = convert_to_dictionary(xls_data)
    assert has_same_dmus is False
    assert validate_data(categories, coefficients) is True

# Path: pyDEA/core/utils/dea_utils.py
# def clean_up_pickled_files():
#     ''' Removes mps-files from current folder and p-files from temporary folder.
#     '''
#     if os.path.exists(TMP_FOLDER):
#         filelist = [f for f in os.listdir(TMP_FOLDER) if f.endswith('.p')]
#         for f in filelist:
#             os.remove(os.path.join(TMP_FOLDER, f))
#     # remove mps file if any
#     filelist = [f for f in os.listdir('.') if f.endswith('.mps')]
#     for f in filelist:
#         os.remove(f)


# Path: tests/utils_for_tests.py
from pulp import LpStatusOptimal
from pyDEA.core.data_processing.read_data_from_xls import read_data
from pyDEA.core.data_processing.read_data_from_xls import construct_input_data_instance
from pyDEA.core.data_processing.read_data_from_xls import validate_data
from pyDEA.core.data_processing.read_data_from_xls import convert_to_dictionary
from pyDEA.core.utils.dea_utils import clean_up_pickled_files
import pytest




EQ_TOLERANCE = 1e-10
WEIGHT_RESTRICTION_TOLERANCE = 1e-7


@pytest.fixture
def DEA_example2_data(request):
    categories, xls_data, dmu_name, sheet_name = read_data(
        'tests/DEA_example2_data.xls')
    coefficients, has_same_dmus = convert_to_dictionary(xls_data)
    assert has_same_dmus is False
    assert validate_data(categories, coefficients) is True

    request.addfinalizer(clean_up_pickled_files)