Exemplo n.º 1
0
    def test_create_read_cell_none(self):
        # prepare
        oCell = Mock(String="foo")

        # play
        rc = create_read_cell(CellTyping.String)

        # verify
        self.assertEqual("foo", rc(oCell))
Exemplo n.º 2
0
    def test_create_read_cell_minimal_value(self, gct):
        # prepare
        oCell = Mock(Value=3.14)
        gct.side_effect = ['VALUE']

        # play
        rc = create_read_cell(CellTyping.Minimal)

        # verify
        self.assertEqual(3.14, rc(oCell))
Exemplo n.º 3
0
    def test_create_read_cell_minimal_text(self, gct):
        # prepare
        oCell = Mock(String="foo")
        gct.side_effect = ['TEXT']

        # play
        rc = create_read_cell(CellTyping.Minimal)

        # verify
        self.assertEqual("foo", rc(oCell))
Exemplo n.º 4
0
    def test_create_read_cell_minimal_empty(self, gct):
        # prepare
        oCell = Mock()
        gct.side_effect = ['EMPTY']

        # play
        rc = create_read_cell(CellTyping.Minimal)

        # verify
        self.assertIsNone(rc(oCell))
Exemplo n.º 5
0
    def test_create_read_cell_accurate_empty(self, gct):
        # prepare
        oCell = Mock()
        oFormats = Mock()
        gct.side_effect = ['EMPTY']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        self.assertIsNone(rc(oCell))
Exemplo n.º 6
0
    def test_create_read_cell_minimal_other(self, gct):
        # prepare
        oCell = Mock()
        gct.side_effect = ['OTHER']

        # play
        rc = create_read_cell(CellTyping.Minimal)

        # verify
        with self.assertRaises(ValueError):
            rc(oCell)
Exemplo n.º 7
0
    def test_create_read_cell_accurate_text(self, gct):
        # prepare
        oCell = Mock(String="foo")
        oFormats = Mock()
        gct.side_effect = ['TEXT']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        self.assertEqual("foo", rc(oCell))
Exemplo n.º 8
0
    def test_create_read_cell_accurate_other(self, gct):
        # prepare
        oCell = Mock()
        oFormats = Mock()
        gct.side_effect = ['']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        with self.assertRaises(ValueError):
            rc(oCell)
Exemplo n.º 9
0
    def test_create_read_cell_accurate_number(self, gct):
        # prepare
        oCell = Mock(Value=10, NumberFormat=3)
        oFormats = Mock()
        oFormats.getByKey.side_effect = [Mock(Type=NumberFormat.NUMBER)]
        gct.side_effect = ['VALUE']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        self.assertEqual(10, rc(oCell))
Exemplo n.º 10
0
    def test_create_read_cell_accurate_logical(self, gct):
        # prepare
        oCell = Mock(Value=1, NumberFormat=3)
        oFormats = Mock()
        oFormats.getByKey.side_effect = [Mock(Type=NumberFormat.LOGICAL)]
        gct.side_effect = ['VALUE']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        self.assertIs(True, rc(oCell))
Exemplo n.º 11
0
    def test_create_read_cell_accurate_date(self, gct):
        # prepare
        oCell = Mock(Value=44000, NumberFormat=3)
        oFormats = Mock()
        oFormats.getByKey.side_effect = [Mock(Type=NumberFormat.DATE)]
        gct.side_effect = ['VALUE']

        # play
        rc = create_read_cell(CellTyping.Accurate, oFormats)

        # verify
        self.assertEqual(dt.datetime(2020, 6, 18, 0, 0), rc(oCell))
Exemplo n.º 12
0
 def test_create_read_cell_other(self):
     with self.assertRaises(ValueError):
         create_read_cell(object())
Exemplo n.º 13
0
 def test_create_read_cell_accurate_wo_formats(self):
     with self.assertRaises(ValueError):
         create_read_cell(CellTyping.Accurate)