1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-22 13:12:22 +01:00
This commit is contained in:
J. Nick Koston
2025-09-16 11:51:44 -05:00
parent 8e13335ff6
commit 7d87dbe641
2 changed files with 34 additions and 23 deletions

View File

@@ -6,6 +6,7 @@ from collections.abc import Callable, Generator
from pathlib import Path
import sys
from typing import Any
from unittest import mock
import pytest
@@ -135,3 +136,23 @@ def generate_main() -> Generator[Callable[[str | Path], str]]:
return CORE.cpp_main_section
yield generator
@pytest.fixture
def mock_clone_or_update() -> Generator[Any]:
"""Mock git.clone_or_update for testing."""
with mock.patch("esphome.git.clone_or_update") as mock_func:
# Default return value
mock_func.return_value = (Path("/tmp/test"), None)
yield mock_func
@pytest.fixture
def mock_load_yaml() -> Generator[Any]:
"""Mock yaml_util.load_yaml for testing."""
from esphome.util import OrderedDict
with mock.patch("esphome.yaml_util.load_yaml") as mock_func:
# Default return value
mock_func.return_value = OrderedDict({"sensor": []})
yield mock_func