Tighten configuration and export handling
This commit is contained in:
@@ -1,22 +1,44 @@
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
from redmine_reporter.cli import main
|
||||
from redmine_reporter.config import Config
|
||||
|
||||
import pytest
|
||||
|
||||
from redmine_reporter.cli import main, parse_date_range
|
||||
|
||||
VALID_ENV = {
|
||||
"REDMINE_URL": "https://red.eltex.loc",
|
||||
"REDMINE_API_KEY": "token",
|
||||
}
|
||||
|
||||
|
||||
# Config читает env при импорте -- патчим класс напрямую.
|
||||
# fetch_issues_with_spent_time импортируется в cli.py через "from .client import ...",
|
||||
# поэтому мокать нужно имя в модуле cli, а не в client.
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="x",
|
||||
REDMINE_PASSWORD="y",
|
||||
@pytest.mark.parametrize(
|
||||
"date_arg, expected",
|
||||
[
|
||||
("2026-01-01--2026-01-31", ("2026-01-01", "2026-01-31")),
|
||||
(" 2026-01-01 -- 2026-01-31 ", ("2026-01-01", "2026-01-31")),
|
||||
],
|
||||
)
|
||||
def test_parse_date_range_valid(date_arg, expected):
|
||||
assert parse_date_range(date_arg) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"date_arg",
|
||||
[
|
||||
"20260101-20260131",
|
||||
"2026-1-01--2026-01-31",
|
||||
"2026-02-30--2026-03-01",
|
||||
"2026-02-01--2026-01-31",
|
||||
],
|
||||
)
|
||||
def test_parse_date_range_invalid(date_arg):
|
||||
with pytest.raises(ValueError):
|
||||
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 задачах."""
|
||||
@@ -31,13 +53,7 @@ def test_cli_smoke_empty(mock_fetch):
|
||||
assert "Total issues: 0" in captured.getvalue()
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="x",
|
||||
REDMINE_PASSWORD="y",
|
||||
)
|
||||
@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):
|
||||
"""None от fetch (нет time entries) -- выход 0."""
|
||||
@@ -46,32 +62,21 @@ def test_cli_returns_zero_on_no_entries(mock_fetch):
|
||||
assert code == 0
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER=None,
|
||||
REDMINE_PASSWORD=None,
|
||||
)
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_cli_config_error():
|
||||
"""Невалидный конфиг -- выход 1."""
|
||||
code = main(["--date", "2026-01-01--2026-01-31"])
|
||||
assert code == 1
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
def test_cli_invalid_date_format():
|
||||
"""Неверный формат даты -- выход 1."""
|
||||
code = main(["--date", "20260101-20260131"])
|
||||
assert code == 1
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="x",
|
||||
REDMINE_PASSWORD="y",
|
||||
)
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
def test_cli_unknown_output_extension(mock_fetch, tmp_path):
|
||||
"""Неизвестное расширение файла -- выход 1."""
|
||||
@@ -81,13 +86,7 @@ def test_cli_unknown_output_extension(mock_fetch, tmp_path):
|
||||
assert code == 1
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="x",
|
||||
REDMINE_PASSWORD="y",
|
||||
)
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
def test_cli_output_without_extension(mock_fetch, tmp_path):
|
||||
"""Файл без расширения -- выход 1 с подсказкой."""
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
import os
|
||||
from unittest import mock
|
||||
|
||||
from redmine_reporter.client import fetch_issues_with_spent_time
|
||||
from redmine_reporter.config import Config
|
||||
from redmine_reporter.config import DEFAULT_REDMINE_VERIFY
|
||||
|
||||
PASSWORD_ENV = {
|
||||
"REDMINE_URL": "https://red.eltex.loc",
|
||||
"REDMINE_USER": "user",
|
||||
"REDMINE_PASSWORD": "password",
|
||||
}
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
)
|
||||
def _configure_current_user(mock_redmine, user_id=1):
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = user_id
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, PASSWORD_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_aggregates_hours_per_issue(mock_redmine_class):
|
||||
"""Два time entry на одну задачу -- часы суммируются."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 123
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine, user_id=123)
|
||||
|
||||
mock_entry1 = mock.MagicMock()
|
||||
mock_entry1.issue.id = 101
|
||||
@@ -41,40 +47,24 @@ def test_fetch_aggregates_hours_per_issue(mock_redmine_class):
|
||||
assert total_hours == 3.5
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
)
|
||||
@mock.patch.dict(os.environ, PASSWORD_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_returns_none_when_no_entries(mock_redmine_class):
|
||||
"""Нет time entries -- возвращается None."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 1
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine)
|
||||
mock_redmine.time_entry.filter.return_value = []
|
||||
|
||||
result = fetch_issues_with_spent_time("2026-01-01", "2026-01-31")
|
||||
assert result is None
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
)
|
||||
@mock.patch.dict(os.environ, PASSWORD_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_skips_entries_without_issue(mock_redmine_class):
|
||||
"""Time entry без привязки к задаче игнорируется."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 1
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine)
|
||||
|
||||
# entry без issue атрибута
|
||||
entry_no_issue = mock.MagicMock(spec=["hours"]) # нет .issue
|
||||
@@ -86,20 +76,12 @@ def test_fetch_skips_entries_without_issue(mock_redmine_class):
|
||||
assert result is None
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
)
|
||||
@mock.patch.dict(os.environ, PASSWORD_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_multiple_issues(mock_redmine_class):
|
||||
"""Несколько задач -- каждая с правильным суммарным временем."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 1
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine)
|
||||
|
||||
def make_entry(issue_id, hours):
|
||||
e = mock.MagicMock()
|
||||
@@ -130,44 +112,38 @@ def test_fetch_multiple_issues(mock_redmine_class):
|
||||
assert hours_by_id[2] == 2.0
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY="api-token",
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
@mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"REDMINE_URL": "https://red.eltex.loc",
|
||||
"REDMINE_API_KEY": "api-token",
|
||||
"REDMINE_USER": "user",
|
||||
"REDMINE_PASSWORD": "password",
|
||||
},
|
||||
clear=True,
|
||||
)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_uses_api_key_when_present(mock_redmine_class):
|
||||
"""Если задан API key, он используется вместо логина/пароля."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 1
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine)
|
||||
mock_redmine.time_entry.filter.return_value = []
|
||||
|
||||
fetch_issues_with_spent_time("2026-01-01", "2026-01-31")
|
||||
|
||||
_, kwargs = mock_redmine_class.call_args
|
||||
assert kwargs["key"] == "api-token"
|
||||
assert kwargs["requests"] == {"verify": DEFAULT_REDMINE_VERIFY}
|
||||
assert "username" not in kwargs
|
||||
assert "password" not in kwargs
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="user",
|
||||
REDMINE_PASSWORD="password",
|
||||
)
|
||||
@mock.patch.dict(os.environ, PASSWORD_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_uses_username_password_when_no_api_key(mock_redmine_class):
|
||||
"""Если API key не задан, остаётся старая схема логин/пароль."""
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
mock_user = mock.MagicMock()
|
||||
mock_user.id = 1
|
||||
mock_redmine.user.get.return_value = mock_user
|
||||
_configure_current_user(mock_redmine)
|
||||
mock_redmine.time_entry.filter.return_value = []
|
||||
|
||||
fetch_issues_with_spent_time("2026-01-01", "2026-01-31")
|
||||
@@ -175,4 +151,18 @@ def test_fetch_uses_username_password_when_no_api_key(mock_redmine_class):
|
||||
_, kwargs = mock_redmine_class.call_args
|
||||
assert kwargs["username"] == "user"
|
||||
assert kwargs["password"] == "password"
|
||||
assert kwargs["requests"] == {"verify": DEFAULT_REDMINE_VERIFY}
|
||||
assert "key" not in kwargs
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, {**PASSWORD_ENV, "REDMINE_VERIFY": "/tmp/redmine-ca.pem"}, clear=True)
|
||||
@mock.patch("redmine_reporter.client.Redmine")
|
||||
def test_fetch_uses_custom_verify_path(mock_redmine_class):
|
||||
mock_redmine = mock_redmine_class.return_value
|
||||
_configure_current_user(mock_redmine)
|
||||
mock_redmine.time_entry.filter.return_value = []
|
||||
|
||||
fetch_issues_with_spent_time("2026-01-01", "2026-01-31")
|
||||
|
||||
_, kwargs = mock_redmine_class.call_args
|
||||
assert kwargs["requests"] == {"verify": "/tmp/redmine-ca.pem"}
|
||||
|
||||
@@ -1,81 +1,101 @@
|
||||
import pytest
|
||||
import os
|
||||
from unittest import mock
|
||||
from redmine_reporter.config import Config
|
||||
|
||||
# Config читает os.getenv() в момент определения класса (class-level атрибуты),
|
||||
# поэтому mock.patch.dict(os.environ) не помогает -- класс уже загружен.
|
||||
# Правильный способ -- патчить атрибуты самого класса.
|
||||
import pytest
|
||||
|
||||
from redmine_reporter.config import DEFAULT_REDMINE_VERIFY, Config
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER="test",
|
||||
REDMINE_PASSWORD="secret",
|
||||
@mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"REDMINE_URL": "https://red.eltex.loc/",
|
||||
"REDMINE_USER": "test",
|
||||
"REDMINE_PASSWORD": "secret",
|
||||
},
|
||||
clear=True,
|
||||
)
|
||||
def test_config_valid_with_password_fallback():
|
||||
Config.validate() # не должно быть исключения
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY="token",
|
||||
REDMINE_USER=None,
|
||||
REDMINE_PASSWORD=None,
|
||||
@mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"REDMINE_URL": "https://red.eltex.loc/",
|
||||
"REDMINE_API_KEY": "token",
|
||||
},
|
||||
clear=True,
|
||||
)
|
||||
def test_config_valid_with_api_key():
|
||||
Config.validate() # не должно быть исключения
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER=None,
|
||||
REDMINE_PASSWORD=None,
|
||||
)
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_config_missing_url():
|
||||
with pytest.raises(ValueError, match="REDMINE_URL"):
|
||||
Config.validate()
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
REDMINE_URL="https://red.eltex.loc",
|
||||
REDMINE_API_KEY=None,
|
||||
REDMINE_USER=None,
|
||||
REDMINE_PASSWORD=None,
|
||||
)
|
||||
@mock.patch.dict(os.environ, {"REDMINE_URL": "https://red.eltex.loc/"}, clear=True)
|
||||
def test_config_missing_auth():
|
||||
with pytest.raises(ValueError, match="REDMINE_API_KEY"):
|
||||
Config.validate()
|
||||
|
||||
|
||||
@mock.patch.multiple(Config, REDMINE_AUTHOR="Иванов И.И.")
|
||||
@mock.patch.dict(os.environ, {"REDMINE_URL": " https://red.eltex.loc/ "}, clear=True)
|
||||
def test_get_redmine_url_strips_spaces_and_trailing_slash():
|
||||
assert Config.get_redmine_url() == "https://red.eltex.loc"
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, {"REDMINE_AUTHOR": " Иванов И.И. "}, clear=True)
|
||||
def test_get_author():
|
||||
assert Config.get_author("") == "Иванов И.И."
|
||||
assert Config.get_author("Петров П.П.") == "Петров П.П."
|
||||
|
||||
|
||||
@mock.patch.multiple(Config, REDMINE_AUTHOR=None)
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_author_fallback():
|
||||
"""Если ни CLI, ни .env не задали автора -- возвращается пустая строка."""
|
||||
assert Config.get_author("") == ""
|
||||
|
||||
|
||||
@mock.patch.multiple(
|
||||
Config,
|
||||
DEFAULT_FROM_DATE="2026-01-01",
|
||||
DEFAULT_TO_DATE="2026-01-31",
|
||||
@mock.patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
"DEFAULT_FROM_DATE": "2026-01-01",
|
||||
"DEFAULT_TO_DATE": "2026-01-31",
|
||||
},
|
||||
clear=True,
|
||||
)
|
||||
def test_get_default_date_range_from_env():
|
||||
assert Config.get_default_date_range() == "2026-01-01--2026-01-31"
|
||||
|
||||
|
||||
@mock.patch.multiple(Config, DEFAULT_FROM_DATE=None, DEFAULT_TO_DATE=None)
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_default_date_range_fallback():
|
||||
"""Если даты не заданы -- используется хардкод-заглушка."""
|
||||
result = Config.get_default_date_range()
|
||||
assert "--" in result # формат YYYY-MM-DD--YYYY-MM-DD
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_redmine_verify_default():
|
||||
assert Config.get_redmine_verify() == DEFAULT_REDMINE_VERIFY
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["0", "false", "False", "no", "off"])
|
||||
def test_get_redmine_verify_false_values(value):
|
||||
with mock.patch.dict(os.environ, {"REDMINE_VERIFY": value}, clear=True):
|
||||
assert Config.get_redmine_verify() is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["1", "true", "True", "yes", "on"])
|
||||
def test_get_redmine_verify_true_values(value):
|
||||
with mock.patch.dict(os.environ, {"REDMINE_VERIFY": value}, clear=True):
|
||||
assert Config.get_redmine_verify() is True
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, {"REDMINE_VERIFY": "/tmp/redmine-ca.pem"}, clear=True)
|
||||
def test_get_redmine_verify_custom_path():
|
||||
assert Config.get_redmine_verify() == "/tmp/redmine-ca.pem"
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import pytest
|
||||
import io
|
||||
from typing import List
|
||||
from unittest import mock
|
||||
from redmine_reporter.types import ReportRow
|
||||
from redmine_reporter.formatters.console import TableFormatter, CompactFormatter
|
||||
|
||||
import pytest
|
||||
from odf.opendocument import OpenDocument, OpenDocumentText
|
||||
|
||||
from redmine_reporter.formatters.console import CompactFormatter, TableFormatter
|
||||
from redmine_reporter.formatters.csv import CSVFormatter
|
||||
from redmine_reporter.formatters.html import HTMLFormatter
|
||||
from redmine_reporter.formatters.markdown import MarkdownFormatter
|
||||
from redmine_reporter.formatters.odt import ODTFormatter
|
||||
from odf.opendocument import OpenDocument, OpenDocumentText
|
||||
from redmine_reporter.types import ReportRow
|
||||
|
||||
|
||||
def _make_empty_odt_bytes() -> bytes:
|
||||
@@ -122,9 +125,7 @@ def odt_formatter():
|
||||
)
|
||||
),
|
||||
):
|
||||
yield ODTFormatter(
|
||||
author="Тест Автор", from_date="2026-01-01", to_date="2026-01-31"
|
||||
)
|
||||
yield ODTFormatter(author="Тест Автор", from_date="2026-01-01", to_date="2026-01-31")
|
||||
|
||||
|
||||
# -- Параметризованные тесты текстовых форматтеров --
|
||||
@@ -184,6 +185,31 @@ def test_compact_formatter_save_raises(fake_rows):
|
||||
CompactFormatter().save(fake_rows, "/dev/null")
|
||||
|
||||
|
||||
def test_markdown_formatter_escapes_table_cells():
|
||||
rows = make_fake_report_rows()
|
||||
rows[0]["project"] = "A|B"
|
||||
rows[0]["display_project"] = "A|B"
|
||||
rows[0]["subject"] = "Fix | split\nline"
|
||||
|
||||
output = MarkdownFormatter().format(rows)
|
||||
|
||||
assert "A\\|B" in output
|
||||
assert "101. Fix \\| split<br>line" in output
|
||||
|
||||
|
||||
def test_html_formatter_escapes_cells():
|
||||
rows = make_fake_report_rows()
|
||||
rows[0]["project"] = 'A&B "<Project>"'
|
||||
rows[0]["display_project"] = rows[0]["project"]
|
||||
rows[0]["subject"] = "Fix <tag> & attrs"
|
||||
|
||||
output = HTMLFormatter().format(rows)
|
||||
|
||||
assert "A&B "<Project>"" in output
|
||||
assert "101. Fix <tag> & attrs" in output
|
||||
assert "Fix <tag>" not in output
|
||||
|
||||
|
||||
# -- Тесты ODT форматтера --
|
||||
|
||||
|
||||
@@ -208,9 +234,7 @@ def test_odt_formatter_save_creates_valid_file(fake_rows, tmp_path):
|
||||
)
|
||||
),
|
||||
):
|
||||
formatter = ODTFormatter(
|
||||
author="Тест", from_date="2026-01-01", to_date="2026-01-31"
|
||||
)
|
||||
formatter = ODTFormatter(author="Тест", from_date="2026-01-01", to_date="2026-01-31")
|
||||
output_file = tmp_path / "report.odt"
|
||||
formatter.save(fake_rows, str(output_file))
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from redmine_reporter.report_builder import build_grouped_report, STATUS_TRANSLATION
|
||||
from redmine_reporter.report_builder import STATUS_TRANSLATION, build_grouped_report
|
||||
|
||||
|
||||
class MockIssue:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from redmine_reporter.utils import (
|
||||
hours_to_human,
|
||||
get_month_name_from_range,
|
||||
get_version,
|
||||
hours_to_human,
|
||||
)
|
||||
|
||||
|
||||
@@ -74,10 +74,7 @@ def test_get_version_without_attribute():
|
||||
|
||||
|
||||
def test_get_version_none_attribute():
|
||||
"""fixed_version = None -- str(None) == 'None', не '<N/A>'."""
|
||||
|
||||
class MockIssue:
|
||||
fixed_version = None
|
||||
|
||||
# get_version возвращает str(getattr(...)), None задан явно -> "None"
|
||||
assert get_version(MockIssue()) == "None"
|
||||
assert get_version(MockIssue()) == "<N/A>"
|
||||
|
||||
Reference in New Issue
Block a user