def test_create_write_cell_minimal_number(self): # prepare oCell = Mock() # play wc = create_write_cell(CellTyping.Minimal) wc(oCell, 10) # verify self.assertEqual(10.0, oCell.Value)
def test_create_write_cell_minimal_bool(self): # prepare oCell = Mock() # play wc = create_write_cell(CellTyping.Minimal) wc(oCell, True) # verify self.assertEqual(1, oCell.Value)
def test_create_write_cell_minimal_date(self): # prepare oCell = Mock() # play wc = create_write_cell(CellTyping.Minimal) wc(oCell, dt.date(2021, 1, 2)) # verify self.assertEqual(44198.0, oCell.Value)
def test_create_write_cell_minimal_string(self): # prepare oCell = Mock() # play wc = create_write_cell(CellTyping.Minimal) wc(oCell, "foo") # verify self.assertEqual("foo", oCell.String)
def test_create_write_cell_string(self): # prepare oCell = Mock() # play wc = create_write_cell(CellTyping.String) wc(oCell, 10) # verify self.assertEqual("10", oCell.String)
def test_create_write_cell_accurate_number(self): # prepare oCell = Mock() oFormats = Mock() # play wc = create_write_cell(CellTyping.Accurate, oFormats) wc(oCell, 10) # verify self.assertEqual(10.0, oCell.Value)
def test_create_write_cell_accurate_string(self): # prepare oCell = Mock() oFormats = Mock() # play wc = create_write_cell(CellTyping.Accurate, oFormats) wc(oCell, "foo") # verify self.assertEqual("foo", oCell.String)
def test_create_write_cell_accurate_bool(self): # prepare oCell = Mock() oFormats = Mock() oFormats.getStandardFormat.side_effect = [1, 2, 3] # play wc = create_write_cell(CellTyping.Accurate, oFormats) wc(oCell, True) # verify self.assertEqual(1, oCell.Value) self.assertEqual(3, oCell.NumberFormat)
def test_create_write_cell_accurate_datetime(self): # prepare oCell = Mock() oFormats = Mock() oFormats.getStandardFormat.side_effect = [1, 2, 3] # play wc = create_write_cell(CellTyping.Accurate, oFormats) wc(oCell, dt.datetime(2020, 1, 1, 4, 5, 6)) # verify self.assertEqual(43831.17020833334, oCell.Value) self.assertEqual(2, oCell.NumberFormat)
def test_create_write_cell_other(self): with self.assertRaises(ValueError): create_write_cell(object())
def test_create_write_cell_accurate_no_format(self): with self.assertRaises(ValueError): create_write_cell(CellTyping.Accurate)