mirror of
https://github.com/home-assistant/core.git
synced 2025-12-22 03:49:36 +00:00
Repository event subscription (#67284)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
"""Test GitHub sensor."""
|
||||
import json
|
||||
|
||||
from homeassistant.components.github.const import DEFAULT_UPDATE_INTERVAL, DOMAIN
|
||||
from homeassistant.components.github.const import DOMAIN, FALLBACK_UPDATE_INTERVAL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import dt
|
||||
|
||||
from .common import TEST_REPOSITORY
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
@@ -22,15 +24,21 @@ async def test_sensor_updates_with_empty_release_array(
|
||||
|
||||
response_json = json.loads(load_fixture("graphql.json", DOMAIN))
|
||||
response_json["data"]["repository"]["release"] = None
|
||||
headers = json.loads(load_fixture("base_headers.json", DOMAIN))
|
||||
|
||||
aioclient_mock.clear_requests()
|
||||
aioclient_mock.get(
|
||||
f"https://api.github.com/repos/{TEST_REPOSITORY}/events",
|
||||
json=[],
|
||||
headers=headers,
|
||||
)
|
||||
aioclient_mock.post(
|
||||
"https://api.github.com/graphql",
|
||||
json=response_json,
|
||||
headers=json.loads(load_fixture("base_headers.json", DOMAIN)),
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
async_fire_time_changed(hass, dt.utcnow() + DEFAULT_UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass, dt.utcnow() + FALLBACK_UPDATE_INTERVAL)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
new_state = hass.states.get(TEST_SENSOR_ENTITY)
|
||||
|
||||
Reference in New Issue
Block a user