Skip to content

Commit

Permalink
Improve config flow test (#3679)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored May 13, 2024
1 parent a679040 commit a730549
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ async def test_flow_with_registration_failure(


async def test_flow_with_activation_failure(
time_freezer: FrozenDateTimeFactory,
hass: HomeAssistant,
_mock_setup_entry: None,
response_mocker: ResponseMocker,
Expand All @@ -243,9 +244,12 @@ async def test_flow_with_activation_failure(
headers={"Content-Type": "application/json"},
),
)
# User has not yet entered the code
response_mocker.add(
url="https://github.com/login/oauth/access_token",
response=MockedResponse(exception=GitHubException("Activation failed")),
response=MockedResponse(
content={"error": "authorization_pending"}, headers={"Content-Type": "application/json"}
),
)

result = await hass.config_entries.flow.async_init(
Expand All @@ -270,6 +274,14 @@ async def test_flow_with_activation_failure(
assert result["step_id"] == "device"
assert result["type"] == FlowResultType.SHOW_PROGRESS

# Activation fails
response_mocker.add(
url="https://github.com/login/oauth/access_token",
response=MockedResponse(exception=GitHubException("Activation failed")),
)

time_freezer.tick(10)

await hass.config_entries.flow.async_configure(result["flow_id"])
await hass.async_block_till_done()
result = await hass.config_entries.flow.async_configure(result["flow_id"])
Expand Down

0 comments on commit a730549

Please sign in to comment.