mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Ensure random temp dir is used during MQTT CI tests (#137221)
This commit is contained in:
parent
a5eda3faf1
commit
30af9057d1
@ -38,7 +38,7 @@ def temp_dir_prefix() -> str:
|
|||||||
return "test"
|
return "test"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture(autouse=True)
|
||||||
def mock_temp_dir(temp_dir_prefix: str) -> Generator[str]:
|
def mock_temp_dir(temp_dir_prefix: str) -> Generator[str]:
|
||||||
"""Mock the certificate temp directory."""
|
"""Mock the certificate temp directory."""
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -4,7 +4,6 @@ import asyncio
|
|||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from random import getrandbits
|
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
@ -199,7 +198,6 @@ async def test_reading_non_exitisting_certificate_file() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("temp_dir_prefix", "unknown")
|
|
||||||
async def test_return_default_get_file_path(
|
async def test_return_default_get_file_path(
|
||||||
hass: HomeAssistant, mock_temp_dir: str
|
hass: HomeAssistant, mock_temp_dir: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -211,12 +209,8 @@ async def test_return_default_get_file_path(
|
|||||||
and mqtt.util.get_file_path("some_option", "mydefault") == "mydefault"
|
and mqtt.util.get_file_path("some_option", "mydefault") == "mydefault"
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
temp_dir = Path(tempfile.gettempdir()) / mock_temp_dir
|
||||||
"homeassistant.components.mqtt.util.TEMP_DIR_NAME",
|
assert await hass.async_add_executor_job(_get_file_path, temp_dir)
|
||||||
f"home-assistant-mqtt-other-{getrandbits(10):03x}",
|
|
||||||
) as temp_dir_name:
|
|
||||||
tempdir = Path(tempfile.gettempdir()) / temp_dir_name
|
|
||||||
assert await hass.async_add_executor_job(_get_file_path, tempdir)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_waiting_for_client_not_loaded(
|
async def test_waiting_for_client_not_loaded(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user