Refactor code structure for improved readability and maintainability

This commit is contained in:
mi222eh
2026-07-06 21:37:20 +02:00
parent 6ca6a5687a
commit 5f35f56edc
48 changed files with 8128 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
from unittest.mock import MagicMock
from gitea.client import GiteaClient
from gitea.tools.git_tools import GitTools
def test_create_branch_success() -> None:
mock_client: MagicMock = MagicMock(spec=GiteaClient)
mock_client.create_ref.return_value = {}
git_tools: GitTools = GitTools(mock_client)
res: str = git_tools.create_branch("owner", "repo", "ref", "sha")
assert res == "Branch 'ref' created successfully in owner/repo."
mock_client.create_ref.assert_called_once_with("owner", "repo", "ref", "sha")
def test_create_branch_failure() -> None:
mock_client: MagicMock = MagicMock(spec=GiteaClient)
mock_client.create_ref.side_effect = Exception("API Error")
git_tools: GitTools = GitTools(mock_client)
res: str = git_tools.create_branch("owner", "repo", "ref", "sha")
assert res == "Error creating branch: API Error"