# Path: rsmtool/test_utils.py
# def copy_data_files(temp_dir_name,
#                     input_file_dict,
#                     given_test_dir):
#     """
#     Copy files from given test directory to a temporary directory.
# 
#     Useful for tests where the current directory is to be used as the
#     reference for resolving paths in the configuration.
# 
#     Parameters
#     ----------
#     temp_dir_name : str
#         Name of the temporary directory.
#     input_file_dict : dict
#         A dictionary of files/directories to copy with keys as the
#         file type and the values are their paths relative to the ``tests``
#         directory.
#     given_test_dir : str
#         Directory where the the test experiments are located. This can be
#         useful when using these experiments to run tests for RSMExtra.
# 
#     Returns
#     -------
#     output_file_dict : dict
#         The dictionary with the same keys as
#         ``input_file_dict`` and values being the copied paths.
#     """
#     temp_dir = Path(temp_dir_name)
#     if not temp_dir.exists():
#         temp_dir.mkdir()
# 
#     output_file_dict = {}
#     for file in input_file_dict:
#         filepath = Path(input_file_dict[file])
#         filename = filepath.name
#         old_filepath = given_test_dir / filepath
#         new_filepath = temp_dir / filename
#         if old_filepath.is_dir():
#             copytree(old_filepath, new_filepath)
#         else:
#             copyfile(old_filepath, new_filepath)
#         output_file_dict[file] = str(new_filepath)
# 
#     return output_file_dict


import os
import shutil
from os.path import join
from pathlib import Path
from nose.tools import eq_, ok_
from rsmtool.test_utils import copy_data_files
    from rsmtool.test_utils import rsmtool_test_dir
else:


class TestCopyData():

    def setUp(self):
        self.dirs_to_remove = []

    def tearDown(self):
        for temp_dir in self.dirs_to_remove:
            shutil.rmtree(temp_dir)

    def test_copy_data_files(self):
        file_dict = {'train': 'data/files/train.csv',
                     'features': 'data/experiments/lr/features.csv'}
        expected_dict = {'train': join('temp_test_copy_data_file', 'train.csv'),
                         'features': join('temp_test_copy_data_file', 'features.csv')}
        self.dirs_to_remove.append('temp_test_copy_data_file')
        output_dict = copy_data_files('temp_test_copy_data_file',
                                      file_dict,
                                      rsmtool_test_dir)
        for file_type in expected_dict:
            eq_(output_dict[file_type], expected_dict[file_type])
            ok_(Path(output_dict[file_type]).exists())
            ok_(Path(output_dict[file_type]).is_file())

    def test_copy_data_files_directory(self):
        file_dict = {'exp_dir': 'data/experiments/lr-self-compare/lr-subgroups'}
        expected_dict = {'exp_dir': join('temp_test_copy_dirs', 'lr-subgroups')}
        self.dirs_to_remove.append('temp_test_copy_dirs')

# Path: rsmtool/test_utils.py
# def copy_data_files(temp_dir_name,
#                     input_file_dict,
#                     given_test_dir):
#     """
#     Copy files from given test directory to a temporary directory.
# 
#     Useful for tests where the current directory is to be used as the
#     reference for resolving paths in the configuration.
# 
#     Parameters
#     ----------
#     temp_dir_name : str
#         Name of the temporary directory.
#     input_file_dict : dict
#         A dictionary of files/directories to copy with keys as the
#         file type and the values are their paths relative to the ``tests``
#         directory.
#     given_test_dir : str
#         Directory where the the test experiments are located. This can be
#         useful when using these experiments to run tests for RSMExtra.
# 
#     Returns
#     -------
#     output_file_dict : dict
#         The dictionary with the same keys as
#         ``input_file_dict`` and values being the copied paths.
#     """
#     temp_dir = Path(temp_dir_name)
#     if not temp_dir.exists():
#         temp_dir.mkdir()
# 
#     output_file_dict = {}
#     for file in input_file_dict:
#         filepath = Path(input_file_dict[file])
#         filename = filepath.name
#         old_filepath = given_test_dir / filepath
#         new_filepath = temp_dir / filename
#         if old_filepath.is_dir():
#             copytree(old_filepath, new_filepath)
#         else:
#             copyfile(old_filepath, new_filepath)
#         output_file_dict[file] = str(new_filepath)
# 
#     return output_file_dict


# Path: tests/test_test_utils.py
import os
import shutil
from os.path import join
from pathlib import Path
from nose.tools import eq_, ok_
from rsmtool.test_utils import copy_data_files
    from rsmtool.test_utils import rsmtool_test_dir

else:


class TestCopyData():

    def setUp(self):
        self.dirs_to_remove = []

    def tearDown(self):
        for temp_dir in self.dirs_to_remove:
            shutil.rmtree(temp_dir)

    def test_copy_data_files(self):
        file_dict = {'train': 'data/files/train.csv',
                     'features': 'data/experiments/lr/features.csv'}
        expected_dict = {'train': join('temp_test_copy_data_file', 'train.csv'),
                         'features': join('temp_test_copy_data_file', 'features.csv')}
        self.dirs_to_remove.append('temp_test_copy_data_file')
        output_dict = copy_data_files('temp_test_copy_data_file',
                                      file_dict,
                                      rsmtool_test_dir)
        for file_type in expected_dict:
            eq_(output_dict[file_type], expected_dict[file_type])
            ok_(Path(output_dict[file_type]).exists())
            ok_(Path(output_dict[file_type]).is_file())

    def test_copy_data_files_directory(self):
        file_dict = {'exp_dir': 'data/experiments/lr-self-compare/lr-subgroups'}
        expected_dict = {'exp_dir': join('temp_test_copy_dirs', 'lr-subgroups')}
        self.dirs_to_remove.append('temp_test_copy_dirs')

        output_dict = copy_data_files('temp_test_copy_dirs',