Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config_flow to bluesound integration #115207

Merged
merged 21 commits into from
Jul 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use AsyncMock assert functions
  • Loading branch information
LouisChrist committed Jul 27, 2024
commit 40274520a315ecde84cceb0241dcd680a6b3b809
25 changes: 13 additions & 12 deletions tests/components/bluesound/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ async def test_user_flow_success(
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "player-name"
assert result["data"] == {CONF_HOST: "1.1.1.1", CONF_PORT: 11000}
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_player_sync_status.mock_calls) == 1

mock_setup_entry.assert_called_once()
mock_player_sync_status.assert_called_once()


async def test_user_flow_cannot_connect(
Expand Down Expand Up @@ -71,7 +72,7 @@ async def test_user_flow_cannot_connect(
}
)

assert len(mock_player_sync_status_client_connection_error.mock_calls) == 1
mock_player_sync_status_client_connection_error.assert_called_once()


async def test_user_flow_aleady_configured(
Expand Down Expand Up @@ -103,7 +104,7 @@ async def test_user_flow_aleady_configured(
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

assert len(mock_player_sync_status.mock_calls) == 1
mock_player_sync_status.assert_called_once()


async def test_import_flow_success(
Expand All @@ -122,8 +123,8 @@ async def test_import_flow_success(
assert result["title"] == "player-name"
assert result["data"] == {CONF_HOST: "1.1.1.1", CONF_PORT: 11000}

assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_player_sync_status.mock_calls) == 1
mock_setup_entry.assert_called_once()
mock_player_sync_status.assert_called_once()


async def test_import_flow_cannot_connect(
Expand All @@ -139,7 +140,7 @@ async def test_import_flow_cannot_connect(
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"

assert len(mock_player_sync_status_client_connection_error.mock_calls) == 1
mock_player_sync_status_client_connection_error.assert_called_once()


async def test_import_flow_already_configured(
Expand All @@ -165,7 +166,7 @@ async def test_import_flow_already_configured(
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

assert len(mock_player_sync_status.mock_calls) == 1
mock_player_sync_status.assert_called_once()


async def test_zeroconf_flow_success(
Expand All @@ -189,8 +190,8 @@ async def test_zeroconf_flow_success(
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"

assert len(mock_setup_entry.mock_calls) == 0
assert len(mock_player_sync_status.mock_calls) == 1
mock_setup_entry.assert_not_called()
mock_player_sync_status.assert_called_once()


async def test_zeroconf_flow_cannot_connect(
Expand All @@ -214,7 +215,7 @@ async def test_zeroconf_flow_cannot_connect(
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"

assert len(mock_player_sync_status_client_connection_error.mock_calls) == 1
mock_player_sync_status_client_connection_error.assert_called_once()


async def test_zeroconf_flow_already_configured(
Expand Down Expand Up @@ -250,4 +251,4 @@ async def test_zeroconf_flow_already_configured(

assert mock_entry.data[CONF_HOST] == "1.1.1.1"

assert len(mock_player_sync_status.mock_calls) == 1
mock_player_sync_status.assert_called_once()