# Path: openpyxl/workbook.py
# class Workbook(object):
#     """Workbook is the container for all other parts of the document."""
# 
#     def __init__(self, optimized_write = False):
#         self.worksheets = []
#         self._active_sheet_index = 0
#         self._named_ranges = []
#         self.properties = DocumentProperties()
#         self.style = Style()
#         self.security = DocumentSecurity()
#         self.__optimized_write = optimized_write
#         self.__optimized_read = False
#         self.strings_table_builder = StringTableBuilder()
# 
#         if not optimized_write:
#             self.worksheets.append(Worksheet(self))
# 
#     def _set_optimized_read(self):
#         self.__optimized_read = True
# 
#     def get_active_sheet(self):
#         """Returns the current active sheet."""
#         return self.worksheets[self._active_sheet_index]
# 
#     def create_sheet(self, index = None):
#         """Create a worksheet (at an optional index).
# 
#         :param index: optional position at which the sheet will be inserted
#         :type index: int
# 
#         """
# 
#         if self.__optimized_read:
#             raise ReadOnlyWorkbookException('Cannot create new sheet in a read-only workbook')
# 
#         if self.__optimized_write :
#             new_ws = DumpWorksheet(parent_workbook = self)
#         else:
#             new_ws = Worksheet(parent_workbook = self)
# 
#         self.add_sheet(worksheet = new_ws, index = index)
#         return new_ws
# 
#     def add_sheet(self, worksheet, index = None):
#         """Add an existing worksheet (at an optional index)."""
#         if index is None:
#             index = len(self.worksheets)
#         self.worksheets.insert(index, worksheet)
# 
#     def remove_sheet(self, worksheet):
#         """Remove a worksheet from this workbook."""
#         self.worksheets.remove(worksheet)
# 
#     def get_sheet_by_name(self, name):
#         """Returns a worksheet by its name.
# 
#         Returns None if no worksheet has the name specified.
# 
#         :param name: the name of the worksheet to look for
#         :type name: string
# 
#         """
#         requested_sheet = None
#         for sheet in self.worksheets:
#             if sheet.title == name:
#                 requested_sheet = sheet
#                 break
#         return requested_sheet
# 
#     def get_index(self, worksheet):
#         """Return the index of the worksheet."""
#         return self.worksheets.index(worksheet)
# 
#     def get_sheet_names(self):
#         """Returns the list of the names of worksheets in the workbook.
# 
#         Names are returned in the worksheets order.
# 
#         :rtype: list of strings
# 
#         """
#         return [s.title for s in self.worksheets]
# 
#     def create_named_range(self, name, worksheet, range):
#         """Create a new named_range on a worksheet"""
#         assert isinstance(worksheet, Worksheet)
#         named_range = NamedRange(name, [(worksheet, range)])
#         self.add_named_range(named_range)
# 
#     def get_named_ranges(self):
#         """Return all named ranges"""
#         return self._named_ranges
# 
#     def add_named_range(self, named_range):
#         """Add an existing named_range to the list of named_ranges."""
#         self._named_ranges.append(named_range)
# 
#     def get_named_range(self, name):
#         """Return the range specified by name."""
#         requested_range = None
#         for named_range in self._named_ranges:
#             if named_range.name == name:
#                 requested_range = named_range
#                 break
#         return requested_range
# 
#     def remove_named_range(self, named_range):
#         """Remove a named_range from this workbook."""
#         self._named_ranges.remove(named_range)
# 
#     def save(self, filename):
#         """ shortcut """
#         if self.__optimized_write:
#             save_dump(self, filename)
#         else:
#             save_workbook(self, filename)


from datetime import time, datetime
from nose.tools import eq_, raises, assert_raises #pylint: disable=E0611
from openpyxl.worksheet import Worksheet
from openpyxl.workbook import Workbook
from openpyxl.shared.exc import ColumnStringIndexException, \
        CellCoordinatesException, DataTypeException
from openpyxl.cell import column_index_from_string, \
        coordinate_from_string, get_column_letter, Cell, absolute_coordinate
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    values = (('03:40:16', time(3, 40, 16)), ('03:40', time(3, 40)),)
    for raw_value, coerced_value in values:
        yield check_time, raw_value, coerced_value


def test_date_format_on_non_date():
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    cell.value = datetime.now()
    cell.value = 'testme'
    eq_('testme', cell.value)

def test_set_get_date():
    today = datetime(2010, 1, 18, 14, 15, 20, 1600)
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    cell.value = today
    eq_(today, cell.value)

def test_repr():
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    eq_(repr(cell), '<Cell Sheet1.A1>', 'Got bad repr: %s' % repr(cell))

def test_is_date():

# Path: openpyxl/workbook.py
# class Workbook(object):
#     """Workbook is the container for all other parts of the document."""
# 
#     def __init__(self, optimized_write = False):
#         self.worksheets = []
#         self._active_sheet_index = 0
#         self._named_ranges = []
#         self.properties = DocumentProperties()
#         self.style = Style()
#         self.security = DocumentSecurity()
#         self.__optimized_write = optimized_write
#         self.__optimized_read = False
#         self.strings_table_builder = StringTableBuilder()
# 
#         if not optimized_write:
#             self.worksheets.append(Worksheet(self))
# 
#     def _set_optimized_read(self):
#         self.__optimized_read = True
# 
#     def get_active_sheet(self):
#         """Returns the current active sheet."""
#         return self.worksheets[self._active_sheet_index]
# 
#     def create_sheet(self, index = None):
#         """Create a worksheet (at an optional index).
# 
#         :param index: optional position at which the sheet will be inserted
#         :type index: int
# 
#         """
# 
#         if self.__optimized_read:
#             raise ReadOnlyWorkbookException('Cannot create new sheet in a read-only workbook')
# 
#         if self.__optimized_write :
#             new_ws = DumpWorksheet(parent_workbook = self)
#         else:
#             new_ws = Worksheet(parent_workbook = self)
# 
#         self.add_sheet(worksheet = new_ws, index = index)
#         return new_ws
# 
#     def add_sheet(self, worksheet, index = None):
#         """Add an existing worksheet (at an optional index)."""
#         if index is None:
#             index = len(self.worksheets)
#         self.worksheets.insert(index, worksheet)
# 
#     def remove_sheet(self, worksheet):
#         """Remove a worksheet from this workbook."""
#         self.worksheets.remove(worksheet)
# 
#     def get_sheet_by_name(self, name):
#         """Returns a worksheet by its name.
# 
#         Returns None if no worksheet has the name specified.
# 
#         :param name: the name of the worksheet to look for
#         :type name: string
# 
#         """
#         requested_sheet = None
#         for sheet in self.worksheets:
#             if sheet.title == name:
#                 requested_sheet = sheet
#                 break
#         return requested_sheet
# 
#     def get_index(self, worksheet):
#         """Return the index of the worksheet."""
#         return self.worksheets.index(worksheet)
# 
#     def get_sheet_names(self):
#         """Returns the list of the names of worksheets in the workbook.
# 
#         Names are returned in the worksheets order.
# 
#         :rtype: list of strings
# 
#         """
#         return [s.title for s in self.worksheets]
# 
#     def create_named_range(self, name, worksheet, range):
#         """Create a new named_range on a worksheet"""
#         assert isinstance(worksheet, Worksheet)
#         named_range = NamedRange(name, [(worksheet, range)])
#         self.add_named_range(named_range)
# 
#     def get_named_ranges(self):
#         """Return all named ranges"""
#         return self._named_ranges
# 
#     def add_named_range(self, named_range):
#         """Add an existing named_range to the list of named_ranges."""
#         self._named_ranges.append(named_range)
# 
#     def get_named_range(self, name):
#         """Return the range specified by name."""
#         requested_range = None
#         for named_range in self._named_ranges:
#             if named_range.name == name:
#                 requested_range = named_range
#                 break
#         return requested_range
# 
#     def remove_named_range(self, named_range):
#         """Remove a named_range from this workbook."""
#         self._named_ranges.remove(named_range)
# 
#     def save(self, filename):
#         """ shortcut """
#         if self.__optimized_write:
#             save_dump(self, filename)
#         else:
#             save_workbook(self, filename)


# Path: openpyxl/tests/test_cell.py
from datetime import time, datetime
from nose.tools import eq_, raises, assert_raises #pylint: disable=E0611
from openpyxl.worksheet import Worksheet
from openpyxl.workbook import Workbook
from openpyxl.shared.exc import ColumnStringIndexException, \
        CellCoordinatesException, DataTypeException
from openpyxl.cell import column_index_from_string, \
        coordinate_from_string, get_column_letter, Cell, absolute_coordinate

    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    values = (('03:40:16', time(3, 40, 16)), ('03:40', time(3, 40)),)
    for raw_value, coerced_value in values:
        yield check_time, raw_value, coerced_value


def test_date_format_on_non_date():
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    cell.value = datetime.now()
    cell.value = 'testme'
    eq_('testme', cell.value)

def test_set_get_date():
    today = datetime(2010, 1, 18, 14, 15, 20, 1600)
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    cell.value = today
    eq_(today, cell.value)

def test_repr():
    wb = Workbook()
    ws = Worksheet(wb)
    cell = Cell(ws, 'A', 1)
    eq_(repr(cell), '<Cell Sheet1.A1>', 'Got bad repr: %s' % repr(cell))

def test_is_date():

    wb = Workbook()