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

25
tests/test_config.py Normal file
View File

@@ -0,0 +1,25 @@
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("Петров П.П.") == "Петров П.П."