Add unit-tests
This commit is contained in:
25
tests/test_config.py
Normal file
25
tests/test_config.py
Normal 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("Петров П.П.") == "Петров П.П."
|
||||
Reference in New Issue
Block a user