Add diagnostics to GitHub integration (#64385)

This commit is contained in:
Joakim Sørensen 2022-01-19 13:41:02 +01:00 committed by GitHub
parent edaf75321e
commit b46b32bafa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 137 additions and 2 deletions

View file

@ -10,10 +10,12 @@ from homeassistant.components.github.const import (
DEFAULT_REPOSITORIES,
DOMAIN,
)
from homeassistant.core import HomeAssistant
from .common import MOCK_ACCESS_TOKEN
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.fixture
@ -32,3 +34,28 @@ def mock_setup_entry() -> Generator[None, None, None]:
"""Mock setting up a config entry."""
with patch("homeassistant.components.github.async_setup_entry", return_value=True):
yield
@pytest.fixture
async def setup_github_integration(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker,
) -> Generator[None, None, None]:
"""Mock setting up the integration."""
aioclient_mock.get(
"https://api.github.com/repos/home-assistant/core",
json={},
headers={"Content-Type": "application/json"},
)
for endpoint in ("issues", "pulls", "releases", "commits"):
aioclient_mock.get(
f"https://api.github.com/repos/home-assistant/core/{endpoint}",
json=[],
headers={"Content-Type": "application/json"},
)
mock_config_entry.options = {CONF_REPOSITORIES: ["home-assistant/core"]}
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()