Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 10
0
 def test_create_write_cell_other(self):
     with self.assertRaises(ValueError):
         create_write_cell(object())
Esempio n. 11
0
 def test_create_write_cell_accurate_no_format(self):
     with self.assertRaises(ValueError):
         create_write_cell(CellTyping.Accurate)