-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Merge Whirlpool tests into a parameterized test #136490
Draft
abmantis
wants to merge
4
commits into
dev
Choose a base branch
from
whirlpool_merge_tests
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−51
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c24e32c
Use fixtures in config flow tests for Whirlpool
abmantis 97cc286
Keep old tests; new one will go to separate PR
abmantis f2de444
Merge Whirlpool tests into a parameterized test
abmantis 8ac23af
Merge branch 'dev' of github.com:home-assistant/core into whirlpool_m…
abmantis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,17 @@ async def test_form_invalid_auth( | |
assert result2["errors"] == {"base": "invalid_auth"} | ||
|
||
|
||
async def test_form_cannot_connect( | ||
@pytest.mark.parametrize( | ||
("exception", "expected_error"), | ||
[ | ||
(aiohttp.ClientConnectionError, "cannot_connect"), | ||
(TimeoutError, "cannot_connect"), | ||
(Exception, "unknown"), | ||
], | ||
) | ||
async def test_form_auth_error( | ||
exception: Exception, | ||
expected_error: str, | ||
hass: HomeAssistant, | ||
region, | ||
brand, | ||
|
@@ -81,7 +91,7 @@ async def test_form_cannot_connect( | |
DOMAIN, context={"source": config_entries.SOURCE_USER} | ||
) | ||
|
||
mock_auth_api.return_value.do_auth.side_effect = aiohttp.ClientConnectionError | ||
mock_auth_api.return_value.do_auth.side_effect = exception | ||
result2 = await hass.config_entries.flow.async_configure( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's reuse |
||
result["flow_id"], | ||
CONFIG_INPUT | ||
|
@@ -91,55 +101,7 @@ async def test_form_cannot_connect( | |
}, | ||
) | ||
assert result2["type"] is FlowResultType.FORM | ||
assert result2["errors"] == {"base": "cannot_connect"} | ||
|
||
|
||
async def test_form_auth_timeout( | ||
hass: HomeAssistant, | ||
region, | ||
brand, | ||
mock_auth_api: MagicMock, | ||
) -> None: | ||
"""Test we handle auth timeout error.""" | ||
result = await hass.config_entries.flow.async_init( | ||
DOMAIN, context={"source": config_entries.SOURCE_USER} | ||
) | ||
|
||
mock_auth_api.return_value.do_auth.side_effect = TimeoutError | ||
result2 = await hass.config_entries.flow.async_configure( | ||
result["flow_id"], | ||
CONFIG_INPUT | ||
| { | ||
"region": region[0], | ||
"brand": brand[0], | ||
}, | ||
) | ||
assert result2["type"] is FlowResultType.FORM | ||
assert result2["errors"] == {"base": "cannot_connect"} | ||
|
||
|
||
async def test_form_generic_auth_exception( | ||
hass: HomeAssistant, | ||
region, | ||
brand, | ||
mock_auth_api: MagicMock, | ||
) -> None: | ||
"""Test we handle cannot connect error.""" | ||
result = await hass.config_entries.flow.async_init( | ||
DOMAIN, context={"source": config_entries.SOURCE_USER} | ||
) | ||
|
||
mock_auth_api.return_value.do_auth.side_effect = Exception | ||
result2 = await hass.config_entries.flow.async_configure( | ||
result["flow_id"], | ||
CONFIG_INPUT | ||
| { | ||
"region": region[0], | ||
"brand": brand[0], | ||
}, | ||
) | ||
assert result2["type"] is FlowResultType.FORM | ||
assert result2["errors"] == {"base": "unknown"} | ||
assert result2["errors"] == {"base": expected_error} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also directly make this test finish in a CREATE ENTRY to also test that it's able to recover |
||
|
||
|
||
@pytest.mark.usefixtures("mock_auth_api", "mock_appliances_manager_api") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have hass as the first parameter