Skip to content

Commit

Permalink
Expand test suite to cover null and empty list values in XLSXListField
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Oct 11, 2024
1 parent 9a0f47f commit 65e8874
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,36 @@ def test_cell_complex_types(self, style: XLSXStyle, worksheet: Worksheet):
assert isinstance(cell, Cell)
assert cell.value == '[{"a": 1}, {"b": 2}]'

def test_cell_with_empty_list(self, style: XLSXStyle, worksheet: Worksheet):
f = XLSXListField(
list_sep=None,
key="objs",
value=[],
field=ListField(),
style=style,
mapping="",
cell_style=style,
)
assert f.original_value == f.value == []
cell = f.cell(worksheet, 1, 1)
assert isinstance(cell, Cell)
assert cell.value == ""

def test_cell_with_null_value(self, style: XLSXStyle, worksheet: Worksheet):
f = XLSXListField(
list_sep=None,
key="objs",
value=None,
field=ListField(allow_null=True),
style=style,
mapping="",
cell_style=style,
)
assert f.original_value is f.value is None
cell = f.cell(worksheet, 1, 1)
assert isinstance(cell, Cell)
assert cell.value is None


class TestXLSXBooleanField:
@pytest.mark.parametrize("value", [True, False])
Expand Down

0 comments on commit 65e8874

Please sign in to comment.