Add unit-tests

This commit is contained in:
Артём Кокос
2026-01-25 12:40:23 +07:00
parent ea90fe79d0
commit d839be8776
5 changed files with 155 additions and 0 deletions

27
tests/test_utils.py Normal file
View File

@@ -0,0 +1,27 @@
import pytest
from redmine_reporter.utils import hours_to_human, get_month_name_from_range, get_version
def test_hours_to_human():
assert hours_to_human(0) == ""
assert hours_to_human(1.0) == ""
assert hours_to_human(2.5) == "2ч 30м"
assert hours_to_human(0.75) == "45м"
assert hours_to_human(3.1666) == "3ч 10м" # ≈ 3ч 10м
def test_get_month_name_from_range():
assert get_month_name_from_range("2026-01-01", "2026-01-31") == "Январь"
assert get_month_name_from_range("2025-12-01", "2026-02-15") == "Февраль" # берётся to_date
assert get_month_name_from_range("invalid", "also_invalid") == "Январь" # fallback
def test_get_version():
class MockIssue:
pass
issue_with = MockIssue()
issue_with.fixed_version = "v2.5.0"
assert get_version(issue_with) == "v2.5.0"
issue_without = MockIssue()
assert get_version(issue_without) == "<N/A>"