# Path: wtframework/wtf/data/data_management.py
# class DataManager(object):
# 
#     """
#     This class is responsible for providing utilities for accessing 
#     test data, the ones stored in the /data folder.  There is a global singleton instance 
#     called 'WTF_DATA_MANAGER' that you can use.
# 
#     The idea of having a DataManager class is so you can remove hard coded references to your 
#     data files.  This allows other people who have a copy of your project in a different location 
#     to be able to run your tests just as easily.
# 
#     Instead of::
# 
#         open("/usr/local/mickey/MyProject/data/testdata.csv")
# 
#     We can reference it without using path information that's specific to where you have your project located.::
# 
#         open(WTF_DATA_MANAGER.get_data_path('testdata.csv')
# 
#     This will look for the 'testdata.csv' file relative to YourProject/data folder.
# 
#     """
# 
#     _data_path = None
# 
#     _DATA_FOLDER_ = u("data")
# 
#     def __init__(self):
#         """
#         Constructor
# 
#         """
#         self._data_path = os.path.join(
#             ProjectUtils.get_project_root(), self._DATA_FOLDER_)
# 
#         if not os.path.exists(self._data_path):
#             raise RuntimeError(
#                 "Missing data folder.  Please check to make sure you have a /data directory.")
# 
#     def get_data_path(self, filename, env_prefix=None):
#         """
#         Get data path.
# 
#         Args:
#             filename (string) : Name of file inside of /data folder to retrieve.
# 
#         Kwargs:
#             env_prefix (string) : Name of subfolder, ex: 'qa' will find files in /data/qa
# 
#         Returns:
#             String - path to file.
# 
#         Usage::
# 
#             open(WTF_DATA_MANAGER.get_data_path('testdata.csv')
# 
#         Note: WTF_DATA_MANAGER is a provided global instance of DataManager
# 
#         """
#         if env_prefix == None:
#             target_file = filename
#         else:
#             target_file = os.path.join(env_prefix, filename)
# 
#         if os.path.exists(os.path.join(self._data_path, target_file)):
#             return os.path.join(self._data_path, target_file)
#         else:
#             raise DataNotFoundError(
#                 u("Cannot find data file: {0}").format(target_file))


from wtframework.wtf.data.data_management import DataManager
import os
import unittest2
#    WTFramework is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    WTFramework is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WTFramework.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################



class TestDataManager(unittest2.TestCase):

    def test_data_manager_returns_filepath(self):
        file_path = DataManager().get_data_path("testdata.csv", "testenv")
        self.assertTrue(os.path.exists(file_path),
                        "Expecting 'testdata.csv' to be under /data/testenv folder.")

    def test_data_manager_returns_filepath_without_env(self):
        file_path = DataManager().get_data_path("testdata1.csv")
        self.assertTrue(os.path.exists(file_path),
                        "Expecting 'testdata1.csv' to be under /data/ folder.")

    def test_data_manager_throws_error_when_data_not_found(self):
        self.assertRaises(

# Path: wtframework/wtf/data/data_management.py
# class DataManager(object):
# 
#     """
#     This class is responsible for providing utilities for accessing 
#     test data, the ones stored in the /data folder.  There is a global singleton instance 
#     called 'WTF_DATA_MANAGER' that you can use.
# 
#     The idea of having a DataManager class is so you can remove hard coded references to your 
#     data files.  This allows other people who have a copy of your project in a different location 
#     to be able to run your tests just as easily.
# 
#     Instead of::
# 
#         open("/usr/local/mickey/MyProject/data/testdata.csv")
# 
#     We can reference it without using path information that's specific to where you have your project located.::
# 
#         open(WTF_DATA_MANAGER.get_data_path('testdata.csv')
# 
#     This will look for the 'testdata.csv' file relative to YourProject/data folder.
# 
#     """
# 
#     _data_path = None
# 
#     _DATA_FOLDER_ = u("data")
# 
#     def __init__(self):
#         """
#         Constructor
# 
#         """
#         self._data_path = os.path.join(
#             ProjectUtils.get_project_root(), self._DATA_FOLDER_)
# 
#         if not os.path.exists(self._data_path):
#             raise RuntimeError(
#                 "Missing data folder.  Please check to make sure you have a /data directory.")
# 
#     def get_data_path(self, filename, env_prefix=None):
#         """
#         Get data path.
# 
#         Args:
#             filename (string) : Name of file inside of /data folder to retrieve.
# 
#         Kwargs:
#             env_prefix (string) : Name of subfolder, ex: 'qa' will find files in /data/qa
# 
#         Returns:
#             String - path to file.
# 
#         Usage::
# 
#             open(WTF_DATA_MANAGER.get_data_path('testdata.csv')
# 
#         Note: WTF_DATA_MANAGER is a provided global instance of DataManager
# 
#         """
#         if env_prefix == None:
#             target_file = filename
#         else:
#             target_file = os.path.join(env_prefix, filename)
# 
#         if os.path.exists(os.path.join(self._data_path, target_file)):
#             return os.path.join(self._data_path, target_file)
#         else:
#             raise DataNotFoundError(
#                 u("Cannot find data file: {0}").format(target_file))


# Path: wtframework/wtf/data/tests/test_data_manager.py
from wtframework.wtf.data.data_management import DataManager
import os
import unittest2

#    WTFramework is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    WTFramework is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WTFramework.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################



class TestDataManager(unittest2.TestCase):

    def test_data_manager_returns_filepath(self):
        file_path = DataManager().get_data_path("testdata.csv", "testenv")
        self.assertTrue(os.path.exists(file_path),
                        "Expecting 'testdata.csv' to be under /data/testenv folder.")

    def test_data_manager_returns_filepath_without_env(self):
        file_path = DataManager().get_data_path("testdata1.csv")
        self.assertTrue(os.path.exists(file_path),
                        "Expecting 'testdata1.csv' to be under /data/ folder.")

    def test_data_manager_throws_error_when_data_not_found(self):
        self.assertRaises(

            RuntimeError, DataManager().get_data_path, "testnodata.csv", "testenv")