Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Sep 2, 2021
1 parent b2bf919 commit 50a08ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ jobs:
-p no:sugar \
--disable-socket \
--allow-unix-socket \
--allow-hosts="127.0.0.1" \
tests
- name: Upload coverage artifact
uses: actions/upload-artifact@v2.2.4
Expand Down
11 changes: 2 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from aiohttp.test_utils import make_mocked_request
import multidict
import pytest
import pytest_socket
import requests_mock as _requests_mock

from homeassistant import core as ha, loader, runner, util
Expand Down Expand Up @@ -320,14 +319,11 @@ def local_auth(hass):


@pytest.fixture
def hass_client(hass, aiohttp_client, hass_access_token):
def hass_client(hass, aiohttp_client, hass_access_token, socket_enabled):
"""Return an authenticated HTTP client."""

async def auth_client():
"""Return an authenticated client."""
# Allow creating sockets, but restricted to 127.0.0.1
pytest_socket.enable_socket()
pytest_socket.socket_allow_hosts("127.0.0.1")
return await aiohttp_client(
hass.http.app, headers={"Authorization": f"Bearer {hass_access_token}"}
)
Expand Down Expand Up @@ -371,16 +367,13 @@ def current_request_with_host(current_request):


@pytest.fixture
def hass_ws_client(aiohttp_client, hass_access_token, hass):
def hass_ws_client(aiohttp_client, hass_access_token, hass, socket_enabled):
"""Websocket client fixture connected to websocket server."""

async def create_client(hass=hass, access_token=hass_access_token):
"""Create a websocket client."""
assert await async_setup_component(hass, "websocket_api", {})

# Allow creating sockets, but restricted to 127.0.0.1
pytest_socket.enable_socket()
pytest_socket.socket_allow_hosts("127.0.0.1")
client = await aiohttp_client(hass.http.app)

with patch("homeassistant.components.http.auth.setup_auth"):
Expand Down

0 comments on commit 50a08ba

Please sign in to comment.