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