25 lines
719 B
Python
25 lines
719 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("Петров П.П.") == "Петров П.П."
|