Skip to content

Commit 82e8a27

Browse files
author
Arturo R Montesinos
committed
Add edge-case fixtures and CLI tests
1 parent e7ebf50 commit 82e8a27

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed
10.9 KB
Binary file not shown.
11.3 KB
Binary file not shown.

tests/fixtures/sparse_edges.ods

9.48 KB
Binary file not shown.

tests/fixtures/unicode_sheets.ods

8.23 KB
Binary file not shown.

tests/test_cli.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,84 @@ def test_multiline_cells_concatenate_paragraphs() -> None:
166166
assert "P1 P2 P3" in stdout_s2
167167

168168

169+
def test_mixed_types_column_fixture_renders_all_values() -> None:
170+
project_root = Path(__file__).resolve().parents[1]
171+
fixture = project_root / "tests" / "fixtures" / "mixed_types_column.ods"
172+
assert fixture.exists()
173+
174+
result = run_cli(str(fixture))
175+
assert result.returncode == 0
176+
stdout = result.stdout
177+
178+
# Headers
179+
for token in ("Row", "Value", "When"):
180+
assert token in stdout
181+
182+
# Label column and mixed values column.
183+
for token in ("R1", "R2", "R3", "R4", "42", "3.14", "Hello"):
184+
assert token in stdout
185+
186+
# Date column: assert that both non-empty date cells render *something*.
187+
# We don't pin the exact locale-specific formatting here, only that the
188+
# year substrings appear.
189+
assert "01/01/24" in stdout
190+
assert "31/12/25" in stdout
191+
192+
193+
def test_long_text_wrapping_fixture_preserves_wide_column_contents() -> None:
194+
project_root = Path(__file__).resolve().parents[1]
195+
fixture = project_root / "tests" / "fixtures" / "long_text_wrapping.ods"
196+
assert fixture.exists()
197+
198+
result = run_cli(str(fixture))
199+
assert result.returncode == 0
200+
stdout = result.stdout
201+
202+
assert "Short" in stdout
203+
assert "VeryLongHeader" in stdout
204+
assert "Short2" in stdout
205+
assert "ok" in stdout
206+
assert "This_is_a_very_long_piece_of_text_with_no_spaces" in stdout
207+
assert "x" in stdout
208+
assert "wrap" in stdout
209+
assert "This cell has several words that may wrap in the terminal" in stdout
210+
assert "y" in stdout
211+
212+
213+
def test_unicode_sheets_fixture_handles_non_ascii_sheet_and_cells() -> None:
214+
project_root = Path(__file__).resolve().parents[1]
215+
fixture = project_root / "tests" / "fixtures" / "unicode_sheets.ods"
216+
assert fixture.exists()
217+
218+
# Default sheet should be accessible without --sheet.
219+
result_default = run_cli(str(fixture))
220+
assert result_default.returncode == 0
221+
stdout_default = result_default.stdout
222+
assert "Default" in stdout_default
223+
224+
# Second sheet with non-ASCII name.
225+
result = run_cli("--sheet", "Σheet-✓", str(fixture))
226+
assert result.returncode == 0
227+
stdout = result.stdout
228+
229+
for token in ("α", "β", "ñandú", "東京", "emoji?", "✓"):
230+
assert token in stdout
231+
232+
233+
def test_sparse_edges_fixture_keeps_outer_empty_rows_and_columns() -> None:
234+
project_root = Path(__file__).resolve().parents[1]
235+
fixture = project_root / "tests" / "fixtures" / "sparse_edges.ods"
236+
assert fixture.exists()
237+
238+
result = run_cli("--range", "A1:D5", str(fixture))
239+
assert result.returncode == 0
240+
stdout = result.stdout
241+
242+
# Inner labels should be present.
243+
for token in ("InnerTop", "InnerCenter", "InnerRight"):
244+
assert token in stdout
245+
246+
169247
def test_parse_range_spec_normalizes_reversed_ranges() -> None:
170248
from odsview.cli import _parse_range_spec
171249

0 commit comments

Comments
 (0)