Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	.gitignore
This commit is contained in:
2026-05-28 14:01:19 +02:00
3 changed files with 61 additions and 4 deletions
@@ -0,0 +1,52 @@
"""Unit tests for docker service utilities."""
from unittest.mock import MagicMock, patch
from src.services.docker import get_container_id, get_container_name
class TestGetContainerId:
"""Tests for get_container_id."""
@patch("subprocess.run")
def test_lowercases_name_for_filter(self, mock_run) -> None:
"""Docker ps name filter is case-sensitive; we must lowercase."""
mock_run.return_value = MagicMock(returncode=0, stdout="abc123\n")
result = get_container_id("MyContainer-ABC")
assert result == "abc123"
call_args = mock_run.call_args[0][0]
# The filter must use lowercase
assert "name=mycontainer-abc" in call_args
@patch("subprocess.run")
def test_returns_none_when_not_found(self, mock_run) -> None:
mock_run.return_value = MagicMock(returncode=0, stdout="")
result = get_container_id("missing")
assert result is None
class TestGetContainerName:
"""Tests for get_container_name."""
@patch("subprocess.run")
def test_lowercases_name_for_filter(self, mock_run) -> None:
"""Docker ps name filter is case-sensitive; we must lowercase."""
mock_run.return_value = MagicMock(returncode=0, stdout="mycontainer-abc\n")
result = get_container_name("MyContainer-ABC")
assert result == "mycontainer-abc"
call_args = mock_run.call_args[0][0]
assert "name=mycontainer-abc" in call_args
@patch("subprocess.run")
def test_returns_none_when_not_found(self, mock_run) -> None:
mock_run.return_value = MagicMock(returncode=0, stdout="")
result = get_container_name("missing")
assert result is None