# Path: openpyxl/tests/helper.py
# DATADIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_data'))
# 
# Path: openpyxl/reader/iter_worksheet.py
# def get_range_boundaries(range_string, row = 0, column = 0):
# 
#     if ':' in range_string:
#         min_range, max_range = range_string.split(':')
#         min_col, min_row = coordinate_from_string(min_range)
#         max_col, max_row = coordinate_from_string(max_range)
# 
#         min_col = column_index_from_string(min_col) + column
#         max_col = column_index_from_string(max_col) + column
#         min_row += row
#         max_row += row
# 
#     else:
#         min_col, min_row = coordinate_from_string(range_string)
#         min_col = column_index_from_string(min_col)
#         max_col = min_col + 1
#         max_row = min_row 
# 
#     return (min_col, min_row, max_col, max_row)
# 
# Path: openpyxl/reader/excel.py
# def load_workbook(filename, use_iterators = False):
#     """Open the given filename and return the workbook
# 
#     :param filename: the path to open
#     :type filename: string
#     
#     :param use_iterators: use lazy load for cells
#     :type use_iterators: bool
# 
#     :rtype: :class:`openpyxl.workbook.Workbook`
#     
#     .. note::
#         
#         When using lazy load, all worksheets will be :class:`openpyxl.reader.iter_worksheet.IterableWorksheet`
#         and the returned workbook will be read-only. 
# 
#     """
# 
#     if isinstance(filename, file):
#         # fileobject must have been opened with 'rb' flag
#         # it is required by zipfile
#         if 'b' not in filename.mode:
#             raise OpenModeError("File-object must be opened in binary mode")
# 
#     try:
#         archive = ZipFile(filename, 'r', ZIP_DEFLATED)
#     except (BadZipfile, RuntimeError, IOError, ValueError), e:
#         raise InvalidFileException(unicode(e))
#     wb = Workbook()
# 
#     if use_iterators:
#         wb._set_optimized_read()
# 
#     try:
#         _load_workbook(wb, archive, filename, use_iterators)
#     except KeyError, e:
#         raise InvalidFileException(unicode(e))
#     finally:
#         archive.close()
#     return wb


from nose.tools import eq_, raises, assert_raises
from openpyxl.tests.helper import DATADIR
from openpyxl.reader.iter_worksheet import get_range_boundaries
from openpyxl.reader.excel import load_workbook
import os.path as osp
import datetime

    workbook_name = osp.join(DATADIR, 'genuine', 'empty.xlsx')

class TestText(TestWorksheet):
    sheet_name = 'Sheet1 - Text'

    expected = [['This is cell A1 in Sheet 1', None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, 'This is cell G5'], ]

    def test_read_fast_integrated(self):

        wb = load_workbook(filename = self.workbook_name, use_iterators = True)
        ws = wb.get_sheet_by_name(name = self.sheet_name)

        for row, expected_row in zip(ws.iter_rows(), self.expected):

            row_values = [x.internal_value for x in row]

            eq_(row_values, expected_row)


    def test_get_boundaries_range(self):

        eq_(get_range_boundaries('C1:C4'), (3, 1, 3, 4))

    def test_get_boundaries_one(self):



# Path: openpyxl/tests/helper.py
# DATADIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_data'))
# 
# Path: openpyxl/reader/iter_worksheet.py
# def get_range_boundaries(range_string, row = 0, column = 0):
# 
#     if ':' in range_string:
#         min_range, max_range = range_string.split(':')
#         min_col, min_row = coordinate_from_string(min_range)
#         max_col, max_row = coordinate_from_string(max_range)
# 
#         min_col = column_index_from_string(min_col) + column
#         max_col = column_index_from_string(max_col) + column
#         min_row += row
#         max_row += row
# 
#     else:
#         min_col, min_row = coordinate_from_string(range_string)
#         min_col = column_index_from_string(min_col)
#         max_col = min_col + 1
#         max_row = min_row 
# 
#     return (min_col, min_row, max_col, max_row)
# 
# Path: openpyxl/reader/excel.py
# def load_workbook(filename, use_iterators = False):
#     """Open the given filename and return the workbook
# 
#     :param filename: the path to open
#     :type filename: string
#     
#     :param use_iterators: use lazy load for cells
#     :type use_iterators: bool
# 
#     :rtype: :class:`openpyxl.workbook.Workbook`
#     
#     .. note::
#         
#         When using lazy load, all worksheets will be :class:`openpyxl.reader.iter_worksheet.IterableWorksheet`
#         and the returned workbook will be read-only. 
# 
#     """
# 
#     if isinstance(filename, file):
#         # fileobject must have been opened with 'rb' flag
#         # it is required by zipfile
#         if 'b' not in filename.mode:
#             raise OpenModeError("File-object must be opened in binary mode")
# 
#     try:
#         archive = ZipFile(filename, 'r', ZIP_DEFLATED)
#     except (BadZipfile, RuntimeError, IOError, ValueError), e:
#         raise InvalidFileException(unicode(e))
#     wb = Workbook()
# 
#     if use_iterators:
#         wb._set_optimized_read()
# 
#     try:
#         _load_workbook(wb, archive, filename, use_iterators)
#     except KeyError, e:
#         raise InvalidFileException(unicode(e))
#     finally:
#         archive.close()
#     return wb


# Path: openpyxl/tests/test_iter.py
from nose.tools import eq_, raises, assert_raises
from openpyxl.tests.helper import DATADIR
from openpyxl.reader.iter_worksheet import get_range_boundaries
from openpyxl.reader.excel import load_workbook
import os.path as osp
import datetime

    workbook_name = osp.join(DATADIR, 'genuine', 'empty.xlsx')

class TestText(TestWorksheet):
    sheet_name = 'Sheet1 - Text'

    expected = [['This is cell A1 in Sheet 1', None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, None],
                [None, None, None, None, None, None, 'This is cell G5'], ]

    def test_read_fast_integrated(self):

        wb = load_workbook(filename = self.workbook_name, use_iterators = True)
        ws = wb.get_sheet_by_name(name = self.sheet_name)

        for row, expected_row in zip(ws.iter_rows(), self.expected):

            row_values = [x.internal_value for x in row]

            eq_(row_values, expected_row)


    def test_get_boundaries_range(self):

        eq_(get_range_boundaries('C1:C4'), (3, 1, 3, 4))

    def test_get_boundaries_one(self):



        eq_(get_range_boundaries('C1'), (3, 1, 4, 1))
