Files
redmine-reporter/tests/test_config.py
Артём Кокос d839be8776 Add unit-tests
2026-01-25 12:40:23 +07:00

26 lines
722 B
Python

import os
import pytest
from unittest import mock
from redmine_reporter.config import Config
@mock.patch.dict(os.environ, {
"REDMINE_URL": "https://red.eltex.loc/",
"REDMINE_USER": "test",
"REDMINE_PASSWORD": "secret"
})
def test_config_valid():
Config.validate() # не должно быть исключения
@mock.patch.dict(os.environ, {}, clear=True)
def test_config_missing():
with pytest.raises(ValueError, match="REDMINE_URL"):
Config.validate()
@mock.patch.dict(os.environ, {"REDMINE_AUTHOR": "Иванов И.И."})
def test_get_author():
assert Config.get_author("") == "Иванов И.И."
assert Config.get_author("Петров П.П.") == "Петров П.П."