Add snapshot testing to YouTube (#96974)
parent
e9eb8a4754
commit
b39f7d6a71
|
@ -0,0 +1,31 @@
|
|||
# serializer version: 1
|
||||
# name: test_sensor
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'entity_picture': 'https://i.ytimg.com/vi/wysukDrMdqU/sddefault.jpg',
|
||||
'friendly_name': 'Google for Developers Latest upload',
|
||||
'icon': 'mdi:youtube',
|
||||
'video_id': 'wysukDrMdqU',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.google_for_developers_latest_upload',
|
||||
'last_changed': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': "What's new in Google Home in less than 1 minute",
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor.1
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'entity_picture': 'https://yt3.ggpht.com/fca_HuJ99xUxflWdex0XViC3NfctBFreIl8y4i9z411asnGTWY-Ql3MeH_ybA4kNaOjY7kyA=s800-c-k-c0x00ffffff-no-rj',
|
||||
'friendly_name': 'Google for Developers Subscribers',
|
||||
'icon': 'mdi:youtube-subscription',
|
||||
'unit_of_measurement': 'subscribers',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.google_for_developers_subscribers',
|
||||
'last_changed': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '2290000',
|
||||
})
|
||||
# ---
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from google.auth.exceptions import RefreshError
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.youtube import DOMAIN
|
||||
|
@ -16,28 +17,17 @@ from .conftest import TOKEN, ComponentSetup
|
|||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
||||
async def test_sensor(hass: HomeAssistant, setup_integration: ComponentSetup) -> None:
|
||||
async def test_sensor(
|
||||
hass: HomeAssistant, snapshot: SnapshotAssertion, setup_integration: ComponentSetup
|
||||
) -> None:
|
||||
"""Test sensor."""
|
||||
await setup_integration()
|
||||
|
||||
state = hass.states.get("sensor.google_for_developers_latest_upload")
|
||||
assert state
|
||||
assert state.name == "Google for Developers Latest upload"
|
||||
assert state.state == "What's new in Google Home in less than 1 minute"
|
||||
assert (
|
||||
state.attributes["entity_picture"]
|
||||
== "https://i.ytimg.com/vi/wysukDrMdqU/sddefault.jpg"
|
||||
)
|
||||
assert state.attributes["video_id"] == "wysukDrMdqU"
|
||||
assert state == snapshot
|
||||
|
||||
state = hass.states.get("sensor.google_for_developers_subscribers")
|
||||
assert state
|
||||
assert state.name == "Google for Developers Subscribers"
|
||||
assert state.state == "2290000"
|
||||
assert (
|
||||
state.attributes["entity_picture"]
|
||||
== "https://yt3.ggpht.com/fca_HuJ99xUxflWdex0XViC3NfctBFreIl8y4i9z411asnGTWY-Ql3MeH_ybA4kNaOjY7kyA=s800-c-k-c0x00ffffff-no-rj"
|
||||
)
|
||||
assert state == snapshot
|
||||
|
||||
|
||||
async def test_sensor_updating(
|
||||
|
|
Loading…
Reference in New Issue