mirror of
https://github.com/home-assistant/core.git
synced 2026-04-29 10:23:46 +02:00
Improve Habitica tests (#153573)
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 70 B |
Binary file not shown.
|
Before Width: | Height: | Size: 70 B |
@@ -87,7 +87,6 @@ async def test_form_login(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> N
|
||||
result["flow_id"],
|
||||
user_input=MOCK_DATA_LOGIN_STEP,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "test-user"
|
||||
@@ -208,7 +207,6 @@ async def test_form_advanced(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||
result["flow_id"],
|
||||
user_input=MOCK_DATA_ADVANCED_STEP,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "test-user"
|
||||
@@ -329,8 +327,6 @@ async def test_flow_reauth(
|
||||
user_input,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert config_entry.data[CONF_API_KEY] == "cd0e5985-17de-4b4f-849e-5d506c5e4382"
|
||||
@@ -399,8 +395,6 @@ async def test_flow_reauth_errors(
|
||||
result["flow_id"], user_input
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": text_error}
|
||||
|
||||
@@ -412,8 +406,6 @@ async def test_flow_reauth_errors(
|
||||
user_input=USER_INPUT_REAUTH_API_KEY,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert config_entry.data[CONF_API_KEY] == "cd0e5985-17de-4b4f-849e-5d506c5e4382"
|
||||
@@ -446,8 +438,6 @@ async def test_flow_reauth_unique_id_mismatch(hass: HomeAssistant) -> None:
|
||||
USER_INPUT_REAUTH_LOGIN,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unique_id_mismatch"
|
||||
|
||||
@@ -469,8 +459,6 @@ async def test_flow_reconfigure(
|
||||
USER_INPUT_RECONFIGURE,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
assert config_entry.data[CONF_API_KEY] == "cd0e5985-17de-4b4f-849e-5d506c5e4382"
|
||||
@@ -507,8 +495,6 @@ async def test_flow_reconfigure_errors(
|
||||
USER_INPUT_RECONFIGURE,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": text_error}
|
||||
|
||||
@@ -519,8 +505,6 @@ async def test_flow_reconfigure_errors(
|
||||
user_input=USER_INPUT_RECONFIGURE,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
assert config_entry.data[CONF_API_KEY] == "cd0e5985-17de-4b4f-849e-5d506c5e4382"
|
||||
|
||||
@@ -12,7 +12,6 @@ from habiticalib import HabiticaGroupsResponse, HabiticaUserResponse
|
||||
import pytest
|
||||
import respx
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.extensions.image import PNGImageSnapshotExtension
|
||||
|
||||
from homeassistant.components.habitica.const import ASSETS_URL, DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
@@ -50,12 +49,8 @@ async def test_image_platform(
|
||||
"homeassistant.components.habitica.coordinator.BytesIO",
|
||||
) as avatar:
|
||||
avatar.side_effect = [
|
||||
BytesIO(
|
||||
b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\rIDATx\xdac\xfc\xcf\xc0\xf0\x1f\x00\x05\x05\x02\x00_\xc8\xf1\xd2\x00\x00\x00\x00IEND\xaeB`\x82"
|
||||
),
|
||||
BytesIO(
|
||||
b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\rIDATx\xdacd`\xf8\xff\x1f\x00\x03\x07\x02\x000&\xc7a\x00\x00\x00\x00IEND\xaeB`\x82"
|
||||
),
|
||||
BytesIO(b"\x89PNGTestImage1"),
|
||||
BytesIO(b"\x89PNGTestImage2"),
|
||||
]
|
||||
|
||||
config_entry.add_to_hass(hass)
|
||||
@@ -77,9 +72,7 @@ async def test_image_platform(
|
||||
resp = await client.get(state.attributes["entity_picture"])
|
||||
assert resp.status == HTTPStatus.OK
|
||||
|
||||
assert (await resp.read()) == snapshot(
|
||||
extension_class=PNGImageSnapshotExtension
|
||||
)
|
||||
assert (await resp.read()) == b"\x89PNGTestImage1"
|
||||
|
||||
habitica.get_user.return_value = HabiticaUserResponse.from_json(
|
||||
await async_load_fixture(hass, "rogue_fixture.json", DOMAIN)
|
||||
@@ -95,9 +88,7 @@ async def test_image_platform(
|
||||
resp = await client.get(state.attributes["entity_picture"])
|
||||
assert resp.status == HTTPStatus.OK
|
||||
|
||||
assert (await resp.read()) == snapshot(
|
||||
extension_class=PNGImageSnapshotExtension
|
||||
)
|
||||
assert (await resp.read()) == b"\x89PNGTestImage2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("habitica")
|
||||
|
||||
Reference in New Issue
Block a user