Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai>
Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai>
Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai>
Co-Authored-By: Vincent Guilloux <vincent.guilloux@mistral.ai>
Co-Authored-By: Clément Siriex <clement.sirieix@mistral.ai>
Co-Authored-By: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-Authored-By: Thaddee Tyl <thaddee.tyl@gmail.com>
Co-Authored-By: David Brochart <david.brochart@gmail.com>
Co-Authored-By: Joseph Guhlin <joseph.guhlin@gmail.com>
Co-Authored-By: Thomas Kenbeek <thomaskenbeek@gmail.com>
Co-Authored-By: Remenby31 <baptiste.cruvellier31@gmail.com>
This commit is contained in:
Mathias Gesbert 2026-01-27 16:39:30 +01:00 committed by Mathias Gesbert
parent 79f215d91c
commit d33db9fff8
217 changed files with 16911 additions and 4305 deletions

View file

@ -0,0 +1,74 @@
from __future__ import annotations
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from vibe.cli.update_notifier.update import do_update
@pytest.mark.asyncio
async def test_do_update_returns_true_when_first_command_succeeds() -> None:
mock_process = MagicMock()
mock_process.wait = AsyncMock(return_value=None)
mock_process.returncode = 0
with patch(
"vibe.cli.update_notifier.update.UPDATE_COMMANDS", ["command_1", "command_2"]
):
with patch(
"vibe.cli.update_notifier.update.asyncio.create_subprocess_shell"
) as mock_create:
mock_create.return_value = mock_process
result = await do_update()
assert result is True
mock_create.assert_called_once()
assert "command_1" in mock_create.call_args[0][0]
@pytest.mark.asyncio
async def test_do_update_returns_true_when_second_command_succeeds() -> None:
mock_process_fail = MagicMock()
mock_process_fail.wait = AsyncMock(return_value=None)
mock_process_fail.returncode = 1
mock_process_success = MagicMock()
mock_process_success.wait = AsyncMock(return_value=None)
mock_process_success.returncode = 0
with patch(
"vibe.cli.update_notifier.update.UPDATE_COMMANDS", ["command_1", "command_2"]
):
with patch(
"vibe.cli.update_notifier.update.asyncio.create_subprocess_shell"
) as mock_create:
mock_create.side_effect = [mock_process_fail, mock_process_success]
result = await do_update()
assert result is True
assert mock_create.call_count == 2
assert "command_1" in mock_create.call_args_list[0][0][0]
assert "command_2" in mock_create.call_args_list[1][0][0]
@pytest.mark.asyncio
async def test_do_update_returns_false_when_all_commands_fail() -> None:
mock_process = MagicMock()
mock_process.wait = AsyncMock(return_value=None)
mock_process.returncode = 1
with patch(
"vibe.cli.update_notifier.update.UPDATE_COMMANDS", ["command_1", "command_2"]
):
with patch(
"vibe.cli.update_notifier.update.asyncio.create_subprocess_shell"
) as mock_create:
mock_create.return_value = mock_process
result = await do_update()
assert result is False
assert mock_create.call_count == 2