mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 19:21:33 +02:00
- Added _is_docker_environment() function - Check endpoint returns is_docker and update_method fields - Apply endpoint rejects Docker with helpful instructions - Added updates API tests - Updated CHANGELOG 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
"""Integration tests for Updates API endpoints."""
|
|
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class TestUpdatesAPI:
|
|
@pytest.mark.asyncio
|
|
async def test_get_version(self, async_client: AsyncClient):
|
|
response = await async_client.get("/api/v1/updates/version")
|
|
assert response.status_code == 200
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_apply_update_docker_rejection(self, async_client: AsyncClient):
|
|
with patch("backend.app.api.routes.updates._is_docker_environment", return_value=True):
|
|
response = await async_client.post("/api/v1/updates/apply")
|
|
result = response.json()
|
|
assert result["success"] is False
|
|
assert result["is_docker"] is True
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_apply_update_non_docker(self, async_client: AsyncClient):
|
|
"""Test non-Docker path - mock _perform_update to prevent side effects."""
|
|
with (
|
|
patch("backend.app.api.routes.updates._is_docker_environment", return_value=False),
|
|
patch("backend.app.api.routes.updates._perform_update", new_callable=AsyncMock),
|
|
):
|
|
response = await async_client.post("/api/v1/updates/apply")
|
|
assert response.json()["success"] is True
|
|
|
|
def test_is_docker_with_dockerenv(self):
|
|
from backend.app.api.routes.updates import _is_docker_environment
|
|
|
|
with patch("os.path.exists", return_value=True):
|
|
assert _is_docker_environment() is True
|
|
|
|
def test_parse_version(self):
|
|
from backend.app.api.routes.updates import parse_version
|
|
|
|
assert parse_version("0.1.5")[:3] == (0, 1, 5)
|
|
|
|
def test_is_newer_version(self):
|
|
from backend.app.api.routes.updates import is_newer_version
|
|
|
|
assert is_newer_version("0.1.5", "0.1.5b7") is True
|