Fix incorrect patch in flume tests (#130631)

pull/130578/head^2
epenet 2024-11-14 19:41:51 +01:00 committed by GitHub
parent 2c8f038c39
commit a97090e0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 25 deletions

View File

@ -3,8 +3,7 @@
from collections.abc import Generator
import datetime
from http import HTTPStatus
import json
from unittest.mock import mock_open, patch
from unittest.mock import patch
import jwt
import pytest
@ -116,7 +115,7 @@ def access_token_fixture(requests_mock: Mocker) -> Generator[None]:
status_code=HTTPStatus.OK,
json={"data": [token_response]},
)
with patch("builtins.open", mock_open(read_data=json.dumps(token_response))):
with patch("homeassistant.components.flume.coordinator.FlumeAuth.write_token_file"):
yield

View File

@ -61,10 +61,6 @@ async def test_form(hass: HomeAssistant) -> None:
assert len(mock_setup_entry.mock_calls) == 1
@pytest.mark.parametrize( # Remove when translations fixed
"ignore_translations",
["component.flume.config.error.invalid_auth"],
)
@pytest.mark.usefixtures("access_token")
async def test_form_invalid_auth(hass: HomeAssistant, requests_mock: Mocker) -> None:
"""Test we handle invalid auth."""
@ -93,10 +89,6 @@ async def test_form_invalid_auth(hass: HomeAssistant, requests_mock: Mocker) ->
assert result2["errors"] == {"password": "invalid_auth"}
@pytest.mark.parametrize( # Remove when translations fixed
"ignore_translations",
["component.flume.config.error.cannot_connect"],
)
@pytest.mark.usefixtures("access_token", "device_list_timeout")
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
"""Test we handle cannot connect error."""
@ -118,16 +110,6 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
assert result2["errors"] == {"base": "cannot_connect"}
@pytest.mark.parametrize( # Remove when translations fixed
"ignore_translations",
[
[
"component.flume.config.abort.reauth_successful",
"component.flume.config.error.cannot_connect",
"component.flume.config.error.invalid_auth",
]
],
)
@pytest.mark.usefixtures("access_token")
async def test_reauth(hass: HomeAssistant, requests_mock: Mocker) -> None:
"""Test we can reauth."""
@ -208,10 +190,6 @@ async def test_reauth(hass: HomeAssistant, requests_mock: Mocker) -> None:
assert result4["reason"] == "reauth_successful"
@pytest.mark.parametrize( # Remove when translations fixed
"ignore_translations",
["component.flume.config.error.cannot_connect"],
)
@pytest.mark.usefixtures("access_token")
async def test_form_no_devices(hass: HomeAssistant, requests_mock: Mocker) -> None:
"""Test a device list response that contains no values will raise an error."""