Fix 9 bugs: ODT covered-cells, CSV BOM, HTML charset, stderr, dead code
- #13 (critical): Add CoveredTableCell elements to ODT for valid row spans (ODF 1.2) - #28: Move "Total issues" info message from stdout to stderr (clean pipe output) - #27: Wrap HTML export in full document with DOCTYPE and meta charset utf-8 - #26: Save CSV with utf-8-sig encoding (UTF-8 BOM for Excel compatibility) - #31: Document CSV uses full project/version values (not display_* like console/MD) - #30: Fix ODT header formatting when author is empty (no leading dot/space) - #36: Remove test_cli_smoke_empty testing unreachable code path (return []) - #37: Remove unused mock_path variable in ODT test fixture - #34: Remove unreachable len(parts) != 2 check in parse_date_range Closes #13, #28, #27, #26, #31, #30, #36, #37, #34
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
@@ -38,21 +36,6 @@ def test_parse_date_range_invalid(date_arg):
|
||||
parse_date_range(date_arg)
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
def test_cli_smoke_empty(mock_fetch):
|
||||
"""Пустой список задач -- выход 0, сообщение о 0 задачах."""
|
||||
mock_fetch.return_value = []
|
||||
captured = StringIO()
|
||||
old_stdout, sys.stdout = sys.stdout, captured
|
||||
try:
|
||||
code = main(["--date", "2026-01-01--2026-01-31"])
|
||||
finally:
|
||||
sys.stdout = old_stdout
|
||||
assert code == 0
|
||||
assert "Total issues: 0" in captured.getvalue()
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
def test_cli_returns_zero_on_no_entries(mock_fetch):
|
||||
@@ -108,3 +91,26 @@ def test_cli_odt_missing_odfpy_message(mock_gf, mock_fetch, tmp_path, capsys):
|
||||
assert code == 1
|
||||
captured = capsys.readouterr()
|
||||
assert "odfpy" in captured.err
|
||||
|
||||
|
||||
class _MockIssue:
|
||||
"""Простой mock Redmine Issue для CLI-тестов."""
|
||||
|
||||
def __init__(self, issue_id=1, subject="Task", project="Project", status="New"):
|
||||
self.id = issue_id
|
||||
self.subject = subject
|
||||
self.project = project
|
||||
self.status = status
|
||||
self.fixed_version = None
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
def test_total_issues_message_goes_to_stderr(mock_fetch, capsys):
|
||||
"""«Total issues» пишется в stderr, не загрязняя stdout при pipe (#28)."""
|
||||
issue = _MockIssue()
|
||||
mock_fetch.return_value = [(issue, 1.0)]
|
||||
main(["--date", "2026-01-01--2026-01-31"])
|
||||
captured = capsys.readouterr()
|
||||
assert "Total issues" not in captured.out
|
||||
assert "Total issues" in captured.err
|
||||
|
||||
Reference in New Issue
Block a user