mirror of
https://github.com/elisspace/core.git
synced 2026-08-29 15:43:55 +00:00
Fix current tests
This commit is contained in:
@@ -64,11 +64,6 @@ class GitHubBaseDataUpdateCoordinator(DataUpdateCoordinator[T]):
|
||||
async def _async_update_data(self) -> T:
|
||||
try:
|
||||
response = await self.fetch_data()
|
||||
scope = (
|
||||
"repo" if self.config_entry.options.get(CONF_REPO_SCOPE, False) else ""
|
||||
)
|
||||
if scope != response.headers.x_oauth_scopes:
|
||||
raise ConfigEntryAuthFailed("Invalid OAuth scopes")
|
||||
except GitHubNotModifiedException:
|
||||
LOGGER.debug(
|
||||
"Content for %s with %s not modified",
|
||||
@@ -92,7 +87,11 @@ class RepositoryInformationDataUpdateCoordinator(
|
||||
|
||||
async def fetch_data(self) -> GitHubResponseModel[GitHubRepositoryModel]:
|
||||
"""Get the latest data from GitHub."""
|
||||
return await self._client.repos.get(self.repository, **{"etag": self._etag})
|
||||
response = await self._client.repos.get(self.repository, **{"etag": self._etag})
|
||||
scope = "repo" if self.config_entry.options.get(CONF_REPO_SCOPE, False) else ""
|
||||
if scope != response.headers.x_oauth_scopes:
|
||||
raise ConfigEntryAuthFailed("Invalid OAuth scopes")
|
||||
return response
|
||||
|
||||
|
||||
class RepositoryReleaseDataUpdateCoordinator(
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
"data": {
|
||||
"repositories": "Select repositories to track."
|
||||
}
|
||||
},
|
||||
"reauth_confirm": {
|
||||
"title": "[%key:common::config_flow::title::reauth%]",
|
||||
"description": "The GitHub integration needs to re-authenticate your account to match the selected scopes."
|
||||
}
|
||||
},
|
||||
"progress": {
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
"wait_for_device": "1. Open {url} \n2.Paste the following key to authorize the integration: \n```\n{code}\n```\n"
|
||||
},
|
||||
"step": {
|
||||
"reauth_confirm": {
|
||||
"description": "The GitHub integration needs to re-authenticate your account to match the selected scopes.",
|
||||
"title": "Reauthenticate Integration"
|
||||
},
|
||||
"repositories": {
|
||||
"data": {
|
||||
"repositories": "Select repositories to track."
|
||||
|
||||
@@ -6,6 +6,7 @@ import pytest
|
||||
|
||||
from homeassistant.components.github.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_REPO_SCOPE,
|
||||
CONF_REPOSITORIES,
|
||||
DOMAIN,
|
||||
)
|
||||
@@ -23,8 +24,9 @@ def mock_config_entry() -> MockConfigEntry:
|
||||
return MockConfigEntry(
|
||||
title="",
|
||||
domain=DOMAIN,
|
||||
unique_id=DOMAIN,
|
||||
data={CONF_ACCESS_TOKEN: MOCK_ACCESS_TOKEN},
|
||||
options={CONF_REPOSITORIES: [TEST_REPOSITORY]},
|
||||
options={CONF_REPOSITORIES: [TEST_REPOSITORY], CONF_REPO_SCOPE: False},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.github.config_flow import starred_repositories
|
||||
from homeassistant.components.github.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_REPO_SCOPE,
|
||||
CONF_REPOSITORIES,
|
||||
DEFAULT_REPOSITORIES,
|
||||
DOMAIN,
|
||||
@@ -62,6 +63,17 @@ async def test_full_user_flow_implementation(
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
|
||||
assert result["step_id"] == "user"
|
||||
assert result["type"] == "form"
|
||||
assert "flow_id" in result
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_REPO_SCOPE: False,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["step_id"] == "device"
|
||||
assert result["type"] == RESULT_TYPE_SHOW_PROGRESS
|
||||
assert "flow_id" in result
|
||||
@@ -92,10 +104,19 @@ async def test_flow_with_registration_failure(
|
||||
"https://github.com/login/device/code",
|
||||
exc=GitHubException("Registration failed"),
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_REPO_SCOPE: False,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result.get("reason") == "could_not_register"
|
||||
|
||||
@@ -124,6 +145,13 @@ async def test_flow_with_activation_failure(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_REPO_SCOPE: False,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["step_id"] == "device"
|
||||
assert result["type"] == RESULT_TYPE_SHOW_PROGRESS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user