Esempio n. 1
0
class FloatColumnTestCase(ColumnTestCase):
    def setUp(self):
        self.column = FloatColumn()

    def test_default_kwargs(self):
        self.assertEqual(self.column.row_style, "Row, decimal")
        self.assertEqual(self.column.default, 0.0)

    def test_override_default_kwargs(self):
        column = FloatColumn(default=1.3, row_style="New style")

        self.assertEqual(column.row_style, "New style")
        self.assertEqual(column.default, 1.3)

    def test_to_excel(self):
        for excel, internal in ((1, 1.0), (1.3, 1.3), (-1.1, -1.1), (0, 0),
                                (self.column.default,
                                 None), (self.column.default, "")):
            self.assertToExcel(excel, internal)

    def test_from_excel(self):
        for excel, internal in ((1, 1.0), (1.1, 1.1), (-1.0, -1.0),
                                ("1.3", 1.3), ("-1.0", -1.0), ("20", 20),
                                ("'3", 3), ("'", 0), ("    0.1   ",
                                                      0.1), (None, 0)):
            self.assertFromExcel(excel, internal)

    def test_unable_to_parse_float(self):
        for value in ("String", object()):
            with self.assertRaises(UnableToParseFloat, msg=value):
                self.column._to_excel(value)

        for value in ("String", ):
            with self.assertRaises(UnableToParseFloat, msg=value):
                self.column._from_excel(FakeCell(value))
Esempio n. 2
0
class IceCreamSheet(TableSheet):
    name = CharColumn()
    description = TextColumn(width=32)
    flavour = CharColumn()
    color = CharColumn()
    price = FloatColumn()

    def create_object(self, row_number, **data):
        return IceCream(**data)
Esempio n. 3
0
class ColumnDemoSheet(TableSheet):
    table_name = "ColumnDemo"

    char = CharColumn(header="CharColumn")
    text = TextColumn(header="TextColumn", freeze=True)
    boolean = BoolColumn(header="BoolColumn",
                         row_style="Row, integer",
                         conditional_formatting=bold_true)
    integer = IntColumn(header="IntColumn", group=True)
    float = FloatColumn(header="FloatColumn", group=True)
    datetime = DatetimeColumn(header="DatetimeColumn", group=True)
    date = DateColumn(header="DateColumn")
    time = TimeColumn(header="TimeColumn", group=True)
    formula = FormulaColumn(header="FormulaColumn",
                            formula="=SUM(ColumnDemo[IntColumn])")
Esempio n. 4
0
    def test_override_default_kwargs(self):
        column = FloatColumn(default=1.3, row_style="New style")

        self.assertEqual(column.row_style, "New style")
        self.assertEqual(column.default, 1.3)
Esempio n. 5
0
 def setUp(self):
     self.column = FloatColumn()