mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Prevent 3rd party lib from opening sockets in ps4 tests (#56330)
This commit is contained in:
parent
327bf24940
commit
55a77b2ba2
@ -1,6 +1,7 @@
|
|||||||
"""Test configuration for PS4."""
|
"""Test configuration for PS4."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from pyps4_2ndscreen.ddp import DEFAULT_UDP_PORT, DDPProtocol
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +26,19 @@ def patch_get_status():
|
|||||||
yield mock_get_status
|
yield mock_get_status
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_ddp_endpoint():
|
||||||
|
"""Mock pyps4_2ndscreen.ddp.async_create_ddp_endpoint."""
|
||||||
|
protocol = DDPProtocol()
|
||||||
|
protocol._local_port = DEFAULT_UDP_PORT
|
||||||
|
protocol._transport = MagicMock()
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.ps4.async_create_ddp_endpoint",
|
||||||
|
return_value=(None, protocol),
|
||||||
|
):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def patch_io(patch_load_json, patch_save_json, patch_get_status):
|
def patch_io(patch_load_json, patch_save_json, patch_get_status, mock_ddp_endpoint):
|
||||||
"""Prevent PS4 doing I/O."""
|
"""Prevent PS4 doing I/O."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user