# Path: wtframework/wtf/data/data_management.py
# class CsvReader(object):
# 
#     """
#     Provides an iterator for accessing CSV records.
#     """
# 
#     _csv_reader = None
#     _headers = None
#     _file = None
# 
#     def __init__(self, file_path):
#         """
#         Constructor
# 
#         Args:
#             file_path (string) : path of CSV file to read.
# 
#         """
#         self._file = open(file_path, 'rb')
# 
#         self._csv_reader = csv.reader(
#             self._file, delimiter=',', dialect='excel')
#         self._headers = self._csv_reader.next()
# 
#     def next(self):
#         """
#         Gets next entry as a dictionary.
# 
#         Returns:
#             object - Object key/value pair representing a row. 
#             {key1: value1, key2: value2, ...}
# 
#         """
#         try:
#             entry = {}
#             row = self._csv_reader.next()
#             for i in range(0, len(row)):
#                 entry[self._headers[i]] = row[i]
# 
#             return entry
#         except Exception as e:
#             # close our file when we're done reading.
#             self._file.close()
#             raise e
# 
#     def __del__(self):
#         # close our file if it's not closed yet.
#         try:
#             self._file.close()
#         except:
#             pass
# 
# WTF_DATA_MANAGER = DataManager()


from wtframework.wtf.data.data_management import CsvReader, WTF_DATA_MANAGER
import unittest2
##########################################################################
# This file is part of WTFramework.
#
#    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 TestCsvReader(unittest2.TestCase):

    def test_csv_reader_reads_csv_file(self):
        csvreader = CsvReader(
            WTF_DATA_MANAGER.get_data_path("testdata.csv", "testenv"))
        first_row = csvreader.next()

# Path: wtframework/wtf/data/data_management.py
# class CsvReader(object):
# 
#     """
#     Provides an iterator for accessing CSV records.
#     """
# 
#     _csv_reader = None
#     _headers = None
#     _file = None
# 
#     def __init__(self, file_path):
#         """
#         Constructor
# 
#         Args:
#             file_path (string) : path of CSV file to read.
# 
#         """
#         self._file = open(file_path, 'rb')
# 
#         self._csv_reader = csv.reader(
#             self._file, delimiter=',', dialect='excel')
#         self._headers = self._csv_reader.next()
# 
#     def next(self):
#         """
#         Gets next entry as a dictionary.
# 
#         Returns:
#             object - Object key/value pair representing a row. 
#             {key1: value1, key2: value2, ...}
# 
#         """
#         try:
#             entry = {}
#             row = self._csv_reader.next()
#             for i in range(0, len(row)):
#                 entry[self._headers[i]] = row[i]
# 
#             return entry
#         except Exception as e:
#             # close our file when we're done reading.
#             self._file.close()
#             raise e
# 
#     def __del__(self):
#         # close our file if it's not closed yet.
#         try:
#             self._file.close()
#         except:
#             pass
# 
# WTF_DATA_MANAGER = DataManager()


# Path: wtframework/wtf/data/tests/test_csv_reader.py
from wtframework.wtf.data.data_management import CsvReader, WTF_DATA_MANAGER
import unittest2

##########################################################################
# This file is part of WTFramework.
#
#    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 TestCsvReader(unittest2.TestCase):

    def test_csv_reader_reads_csv_file(self):
        csvreader = CsvReader(
            WTF_DATA_MANAGER.get_data_path("testdata.csv", "testenv"))
        first_row = csvreader.next()

        self.assertEqual("Dog", first_row['Animal'])