Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
 def test_create_write_cell_other(self):
     with self.assertRaises(ValueError):
         create_write_cell(object())
Example #11
0
 def test_create_write_cell_accurate_no_format(self):
     with self.assertRaises(ValueError):
         create_write_cell(CellTyping.Accurate)