GRM-136: refactor: rename PyPI package from gitea-runner-manager to grm
Post-merge / detect-type (push) Successful in 53s
Post-merge / release (push) Successful in 1m14s
Post-merge / validate-commit-msg (push) Successful in 1m25s
Post-merge / vikunja (push) Successful in 1m21s
Post-merge / badges (push) Successful in 1m45s
Post-merge / configure-repo (push) Successful in 1m15s
Post-merge / sync-wiki (push) Successful in 3m5s
Post-merge / publish (push) Successful in 1m1s
Post-merge / detect-type (push) Successful in 53s
Post-merge / release (push) Successful in 1m14s
Post-merge / validate-commit-msg (push) Successful in 1m25s
Post-merge / vikunja (push) Successful in 1m21s
Post-merge / badges (push) Successful in 1m45s
Post-merge / configure-repo (push) Successful in 1m15s
Post-merge / sync-wiki (push) Successful in 3m5s
Post-merge / publish (push) Successful in 1m1s
This commit was merged in pull request #203.
This commit is contained in:
@@ -7,8 +7,8 @@ from unittest.mock import MagicMock, mock_open, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from gitea_runner_manager.exceptions import AnsibleError
|
||||
from gitea_runner_manager.executor import AnsibleExecutor
|
||||
from grm.exceptions import AnsibleError
|
||||
from grm.executor import AnsibleExecutor
|
||||
|
||||
|
||||
def _mock_popen_process(returncode: int = 0) -> MagicMock:
|
||||
@@ -22,7 +22,7 @@ def _mock_popen_process(returncode: int = 0) -> MagicMock:
|
||||
|
||||
class TestAnsibleExecutorRun:
|
||||
def test_run_success(self, tmp_path: Path) -> None:
|
||||
with patch("gitea_runner_manager.executor.say") as mock_say:
|
||||
with patch("grm.executor.say") as mock_say:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open()):
|
||||
mock_popen.return_value = _mock_popen_process(returncode=0)
|
||||
@@ -33,7 +33,7 @@ class TestAnsibleExecutorRun:
|
||||
assert any("Done" in msg for msg in messages)
|
||||
|
||||
def test_run_failure(self, tmp_path: Path) -> None:
|
||||
with patch("gitea_runner_manager.executor.say") as mock_say:
|
||||
with patch("grm.executor.say") as mock_say:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open()):
|
||||
mock_popen.return_value = _mock_popen_process(returncode=1)
|
||||
@@ -45,7 +45,7 @@ class TestAnsibleExecutorRun:
|
||||
assert "exit code 1" in error_calls[0].args[0]
|
||||
|
||||
def test_run_default_description(self, tmp_path: Path) -> None:
|
||||
with patch("gitea_runner_manager.executor.say") as mock_say:
|
||||
with patch("grm.executor.say") as mock_say:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open()):
|
||||
mock_popen.return_value = _mock_popen_process(returncode=0)
|
||||
@@ -75,7 +75,7 @@ class TestAnsibleExecutorRun:
|
||||
' "msg": "Runner \'127.0.0.1\' is installed and running."\n'
|
||||
"}\n"
|
||||
)
|
||||
with patch("gitea_runner_manager.executor.say") as mock_say:
|
||||
with patch("grm.executor.say") as mock_say:
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open(read_data=log_content)):
|
||||
mock_popen.return_value = _mock_popen_process(returncode=0)
|
||||
@@ -111,7 +111,7 @@ class TestAnsibleExecutorExtractStatus:
|
||||
executor = AnsibleExecutor()
|
||||
log_file = tmp_path / "test.log"
|
||||
log_file.write_text("incomplete")
|
||||
with patch("gitea_runner_manager.executor.open", side_effect=OSError("read error")):
|
||||
with patch("grm.executor.open", side_effect=OSError("read error")):
|
||||
status = executor._extract_status(log_file)
|
||||
assert status is None
|
||||
|
||||
@@ -138,7 +138,7 @@ class TestAnsibleExecutorTranslation:
|
||||
def test_run_translated(self, tmp_path: Path) -> None:
|
||||
with (
|
||||
patch.dict(os.environ, {"GRM_LANG": "de"}),
|
||||
patch("gitea_runner_manager.executor.say") as mock_say,
|
||||
patch("grm.executor.say") as mock_say,
|
||||
):
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open()):
|
||||
@@ -152,7 +152,7 @@ class TestAnsibleExecutorTranslation:
|
||||
def test_unsupported_lang_fallback(self, tmp_path: Path) -> None:
|
||||
with (
|
||||
patch.dict(os.environ, {"GRM_LANG": "xx"}),
|
||||
patch("gitea_runner_manager.executor.say") as mock_say,
|
||||
patch("grm.executor.say") as mock_say,
|
||||
):
|
||||
executor = AnsibleExecutor(log_dir=tmp_path)
|
||||
with patch("subprocess.Popen") as mock_popen, patch("builtins.open", mock_open()):
|
||||
|
||||
Reference in New Issue
Block a user