Add unit-tests
This commit is contained in:
23
tests/test_cli.py
Normal file
23
tests/test_cli.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import sys
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
from redmine_reporter.cli import main
|
||||
|
||||
|
||||
@mock.patch.dict("os.environ", {
|
||||
"REDMINE_URL": "https://red.eltex.loc/",
|
||||
"REDMINE_USER": "x",
|
||||
"REDMINE_PASSWORD": "y"
|
||||
})
|
||||
@mock.patch("redmine_reporter.client.fetch_issues_with_spent_time")
|
||||
def test_cli_smoke(mock_fetch):
|
||||
mock_fetch.return_value = []
|
||||
old_stdout = sys.stdout
|
||||
sys.stdout = captured = StringIO()
|
||||
try:
|
||||
code = main(["--date", "2026-01-01--2026-01-31"])
|
||||
assert code == 0
|
||||
output = captured.getvalue()
|
||||
assert "Total issues: 0" in output
|
||||
finally:
|
||||
sys.stdout = old_stdout
|
||||
Reference in New Issue
Block a user