feat: JSON, Excel export and time summary
- #23: add JSONFormatter and XLSXFormatter - add openpyxl dependency for .xlsx export - #22: add --summary flag and calculate_summary() in report_builder - ReportRow now carries raw hours for summary calculations - update CLI help and README with .json/.xlsx formats and --summary - add tests for new formatters and summary computation Closes #22, closes #23
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from redmine_reporter.report_builder import (
|
||||
STATUS_TRANSLATION,
|
||||
build_grouped_report,
|
||||
calculate_summary,
|
||||
group_rows_by_project_and_version,
|
||||
)
|
||||
|
||||
@@ -60,7 +61,61 @@ def test_build_grouped_report_grouping():
|
||||
|
||||
assert rows[0]["status_ru"] == "В работе"
|
||||
assert rows[0]["time_text"] == "2ч"
|
||||
assert rows[0]["hours"] == 2.0
|
||||
assert rows[1]["time_text"] == "1ч 30м"
|
||||
assert rows[1]["hours"] == 1.5
|
||||
|
||||
|
||||
# -- #22: Сводка по времени --
|
||||
|
||||
|
||||
def test_calculate_summary_totals():
|
||||
"""Сводка содержит общее время и разбивку по проектам/версиям."""
|
||||
rows = [
|
||||
{
|
||||
"project": "Камеры",
|
||||
"version": "v2.5.0",
|
||||
"issue_id": 101,
|
||||
"subject": "Фича A",
|
||||
"status_ru": "В работе",
|
||||
"time_text": "2ч",
|
||||
"hours": 2.0,
|
||||
},
|
||||
{
|
||||
"project": "Камеры",
|
||||
"version": "v2.5.0",
|
||||
"issue_id": 102,
|
||||
"subject": "Баг B",
|
||||
"status_ru": "Решена",
|
||||
"time_text": "1ч 30м",
|
||||
"hours": 1.5,
|
||||
},
|
||||
{
|
||||
"project": "ПО",
|
||||
"version": "<N/A>",
|
||||
"issue_id": 201,
|
||||
"subject": "Доки",
|
||||
"status_ru": "Ожидание",
|
||||
"time_text": "4ч",
|
||||
"hours": 4.0,
|
||||
},
|
||||
]
|
||||
summary = calculate_summary(rows)
|
||||
|
||||
assert summary["total"] == 7.5
|
||||
assert summary["project:Камеры"] == 3.5
|
||||
assert summary["project:ПО"] == 4.0
|
||||
assert summary["version:Камеры::v2.5.0"] == 3.5
|
||||
assert summary["version:ПО::<N/A>"] == 4.0
|
||||
|
||||
|
||||
def test_calculate_summary_empty():
|
||||
"""Сводка для пустого списка -- только total = 0."""
|
||||
summary = calculate_summary([])
|
||||
assert summary == {"total": 0.0}
|
||||
|
||||
|
||||
# -- #19: Общая функция группировки --
|
||||
|
||||
|
||||
def test_build_grouped_report_new_version_same_project():
|
||||
|
||||
Reference in New Issue
Block a user