feat(user): report on another user's time entries

- Add user_id parameter to fetch_issues_with_spent_time().
- Support numeric ID, login, or full name resolution.
- Reject ambiguous names and unknown users with clear messages.
- Add CLI flags: --user-id, --user-login, --user-name.
- Only allow one user flag at a time.
- Add ResourceNotFoundError handling.
- Update README with usage examples.
- Add tests for user resolution and CLI flags.

Closes #40
This commit is contained in:
Кокос Артем Николаевич
2026-06-29 15:15:17 +07:00
parent 67b5d093d9
commit f6861382e6
7 changed files with 259 additions and 11 deletions

View File

@@ -265,3 +265,39 @@ def test_cli_no_time_passed_to_formatter(mock_fetch, tmp_path):
_, kwargs = mock_get_formatter.call_args
assert kwargs.get("no_time") is True
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
def test_cli_passes_user_id_to_fetch(mock_fetch):
"""CLI --user-id передаётся в fetch_issues_with_spent_time."""
mock_fetch.return_value = None
main(["--date", "2026-01-01--2026-01-31", "--user-id", "42"])
_, kwargs = mock_fetch.call_args
assert kwargs["user_id"] == "42"
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
def test_cli_passes_user_login_to_fetch(mock_fetch):
"""CLI --user-login передаётся в fetch_issues_with_spent_time."""
mock_fetch.return_value = None
main(["--date", "2026-01-01--2026-01-31", "--user-login", "ivanov"])
_, kwargs = mock_fetch.call_args
assert kwargs["user_id"] == "ivanov"
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
def test_cli_rejects_multiple_user_flags():
"""CLI не принимает одновременно несколько флагов пользователя."""
code = main(
[
"--date",
"2026-01-01--2026-01-31",
"--user-id",
"42",
"--user-login",
"ivanov",
]
)
assert code == 1