Use snapshot assertion for iqvia diagnostics test (#98983)

This commit is contained in:
Jan-Philipp Benecke 2023-08-24 23:26:21 +02:00 committed by GitHub
parent 4d8941d4b7
commit 3bcd1d5a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 381 additions and 336 deletions

View file

@ -13,7 +13,12 @@ from tests.common import MockConfigEntry, load_fixture
@pytest.fixture(name="config_entry")
def config_entry_fixture(hass, config):
"""Define a config entry fixture."""
entry = MockConfigEntry(domain=DOMAIN, unique_id=config[CONF_ZIP_CODE], data=config)
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=config[CONF_ZIP_CODE],
data=config,
entry_id="690ac4b7e99855fc5ee7b987a758d5cb",
)
entry.add_to_hass(hass)
return entry

View file

@ -0,0 +1,363 @@
# serializer version: 1
# name: test_entry_diagnostics
dict({
'data': dict({
'allergy_average_forecasted': dict({
'ForecastDate': '2018-06-12T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Index': 6.6,
'Period': '2018-06-12T13:47:12.897',
}),
dict({
'Index': 6.3,
'Period': '2018-06-13T13:47:12.897',
}),
dict({
'Index': 7.6,
'Period': '2018-06-14T13:47:12.897',
}),
dict({
'Index': 7.6,
'Period': '2018-06-15T13:47:12.897',
}),
dict({
'Index': 7.3,
'Period': '2018-06-16T13:47:12.897',
}),
]),
}),
'Type': 'pollen',
}),
'allergy_index': dict({
'ForecastDate': '2018-06-12T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Index': 7.2,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
dict({
'Genus': 'Juniperus',
'LGID': 272,
'Name': 'Juniper',
'PlantType': 'Tree',
}),
dict({
'Genus': 'Grasses',
'LGID': 346,
'Name': 'Grasses',
'PlantType': 'Grass',
}),
dict({
'Genus': 'Chenopods',
'LGID': 63,
'Name': 'Chenopods',
'PlantType': 'Ragweed',
}),
]),
'Type': 'Yesterday',
}),
dict({
'Index': 6.6,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
dict({
'Genus': 'Juniperus',
'LGID': 272,
'Name': 'Juniper',
'PlantType': 'Tree',
}),
dict({
'Genus': 'Grasses',
'LGID': 346,
'Name': 'Grasses',
'PlantType': 'Grass',
}),
dict({
'Genus': 'Chenopods',
'LGID': 63,
'Name': 'Chenopods',
'PlantType': 'Ragweed',
}),
]),
'Type': 'Today',
}),
dict({
'Index': 6.3,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
dict({
'Genus': 'Juniperus',
'LGID': 272,
'Name': 'Juniper',
'PlantType': 'Tree',
}),
dict({
'Genus': 'Grasses',
'LGID': 346,
'Name': 'Grasses',
'PlantType': 'Grass',
}),
dict({
'Genus': 'Chenopods',
'LGID': 63,
'Name': 'Chenopods',
'PlantType': 'Ragweed',
}),
]),
'Type': 'Tomorrow',
}),
]),
}),
'Type': 'pollen',
}),
'allergy_outlook': dict({
'Market': '**REDACTED**',
'Outlook': 'The amount of pollen in the air for Wednesday...',
'Season': 'Tree',
'Trend': 'subsiding',
'TrendID': 4,
'ZIP': '**REDACTED**',
}),
'asthma_average_forecasted': dict({
'ForecastDate': '2018-10-28T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Idx': '4.5',
'Index': 4.5,
'Period': '2018-10-28T05:45:01.45',
}),
dict({
'Idx': '4.7',
'Index': 4.7,
'Period': '2018-10-29T05:45:01.45',
}),
dict({
'Idx': '5.0',
'Index': 5,
'Period': '2018-10-30T05:45:01.45',
}),
dict({
'Idx': '5.2',
'Index': 5.2,
'Period': '2018-10-31T05:45:01.45',
}),
dict({
'Idx': '5.5',
'Index': 5.5,
'Period': '2018-11-01T05:45:01.45',
}),
]),
}),
'Type': 'asthma',
}),
'asthma_index': dict({
'ForecastDate': '2018-10-29T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Idx': '4.1',
'Index': 4.1,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
dict({
'Description': 'Ozone (O3) is a odorless, colorless ....',
'LGID': 1,
'Name': 'OZONE',
'PPM': 42,
}),
dict({
'Description': 'Fine particles (PM2.5) are 2.5 ...',
'LGID': 1,
'Name': 'PM2.5',
'PPM': 30,
}),
dict({
'Description': 'Coarse dust particles (PM10) are 2.5 ...',
'LGID': 1,
'Name': 'PM10',
'PPM': 19,
}),
]),
'Type': 'Yesterday',
}),
dict({
'Idx': '4.5',
'Index': 4.5,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
dict({
'Description': 'Fine particles (PM2.5) are 2.5 ...',
'LGID': 3,
'Name': 'PM2.5',
'PPM': 105,
}),
dict({
'Description': 'Coarse dust particles (PM10) are 2.5 ...',
'LGID': 2,
'Name': 'PM10',
'PPM': 65,
}),
dict({
'Description': 'Ozone (O3) is a odorless, colorless ...',
'LGID': 1,
'Name': 'OZONE',
'PPM': 42,
}),
]),
'Type': 'Today',
}),
dict({
'Idx': '4.6',
'Index': 4.6,
'Period': '0001-01-01T00:00:00',
'Triggers': list([
]),
'Type': 'Tomorrow',
}),
]),
}),
'Type': 'asthma',
}),
'disease_average_forecasted': dict({
'ForecastDate': '2018-06-12T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Index': 2.4,
'Period': '2018-06-12T05:13:51.817',
}),
dict({
'Index': 2.5,
'Period': '2018-06-13T05:13:51.817',
}),
dict({
'Index': 2.5,
'Period': '2018-06-14T05:13:51.817',
}),
dict({
'Index': 2.5,
'Period': '2018-06-15T05:13:51.817',
}),
]),
}),
'Type': 'cold',
}),
'disease_index': dict({
'ForecastDate': '2019-04-07T00:00:00-04:00',
'Location': dict({
'City': '**REDACTED**',
'DisplayLocation': '**REDACTED**',
'State': '**REDACTED**',
'ZIP': '**REDACTED**',
'periods': list([
dict({
'Idx': '6.8',
'Index': 6.8,
'Period': '2019-04-06T00:00:00',
'Triggers': list([
dict({
'Description': 'Influenza',
'Idx': '3.1',
'Index': 3.1,
'Name': 'Flu',
}),
dict({
'Description': 'High Fever',
'Idx': '6.2',
'Index': 6.2,
'Name': 'Fever',
}),
dict({
'Description': 'Strep & Sore throat',
'Idx': '5.2',
'Index': 5.2,
'Name': 'Strep',
}),
dict({
'Description': 'Cough',
'Idx': '7.8',
'Index': 7.8,
'Name': 'Cough',
}),
]),
'Type': 'Yesterday',
}),
dict({
'Idx': '6.7',
'Index': 6.7,
'Period': '2019-04-07T03:52:58',
'Triggers': list([
dict({
'Description': 'Influenza',
'Idx': '3.1',
'Index': 3.1,
'Name': 'Flu',
}),
dict({
'Description': 'High Fever',
'Idx': '5.9',
'Index': 5.9,
'Name': 'Fever',
}),
dict({
'Description': 'Strep & Sore throat',
'Idx': '5.1',
'Index': 5.1,
'Name': 'Strep',
}),
dict({
'Description': 'Cough',
'Idx': '7.7',
'Index': 7.7,
'Name': 'Cough',
}),
]),
'Type': 'Today',
}),
]),
}),
'Type': 'cold',
}),
}),
'entry': dict({
'data': dict({
'zip_code': '**REDACTED**',
}),
'disabled_by': None,
'domain': 'iqvia',
'entry_id': '690ac4b7e99855fc5ee7b987a758d5cb',
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'title': '**REDACTED**',
'unique_id': '**REDACTED**',
'version': 1,
}),
})
# ---

View file

@ -1,5 +1,6 @@
"""Test IQVIA diagnostics."""
from homeassistant.components.diagnostics import REDACTED
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.components.diagnostics import get_diagnostics_for_config_entry
@ -7,339 +8,15 @@ from tests.typing import ClientSessionGenerator
async def test_entry_diagnostics(
hass: HomeAssistant, config_entry, hass_client: ClientSessionGenerator, setup_iqvia
hass: HomeAssistant,
config_entry,
hass_client: ClientSessionGenerator,
setup_iqvia,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
"entry": {
"entry_id": config_entry.entry_id,
"version": 1,
"domain": "iqvia",
"title": REDACTED,
"data": {"zip_code": REDACTED},
"options": {},
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"source": "user",
"unique_id": REDACTED,
"disabled_by": None,
},
"data": {
"allergy_average_forecasted": {
"Type": "pollen",
"ForecastDate": "2018-06-12T00:00:00-04:00",
"Location": {
"ZIP": REDACTED,
"City": REDACTED,
"State": REDACTED,
"periods": [
{"Period": "2018-06-12T13:47:12.897", "Index": 6.6},
{"Period": "2018-06-13T13:47:12.897", "Index": 6.3},
{"Period": "2018-06-14T13:47:12.897", "Index": 7.6},
{"Period": "2018-06-15T13:47:12.897", "Index": 7.6},
{"Period": "2018-06-16T13:47:12.897", "Index": 7.3},
],
"DisplayLocation": REDACTED,
},
},
"allergy_index": {
"Type": "pollen",
"ForecastDate": "2018-06-12T00:00:00-04:00",
"Location": {
"ZIP": REDACTED,
"City": REDACTED,
"State": REDACTED,
"periods": [
{
"Triggers": [
{
"LGID": 272,
"Name": "Juniper",
"Genus": "Juniperus",
"PlantType": "Tree",
},
{
"LGID": 346,
"Name": "Grasses",
"Genus": "Grasses",
"PlantType": "Grass",
},
{
"LGID": 63,
"Name": "Chenopods",
"Genus": "Chenopods",
"PlantType": "Ragweed",
},
],
"Period": "0001-01-01T00:00:00",
"Type": "Yesterday",
"Index": 7.2,
},
{
"Triggers": [
{
"LGID": 272,
"Name": "Juniper",
"Genus": "Juniperus",
"PlantType": "Tree",
},
{
"LGID": 346,
"Name": "Grasses",
"Genus": "Grasses",
"PlantType": "Grass",
},
{
"LGID": 63,
"Name": "Chenopods",
"Genus": "Chenopods",
"PlantType": "Ragweed",
},
],
"Period": "0001-01-01T00:00:00",
"Type": "Today",
"Index": 6.6,
},
{
"Triggers": [
{
"LGID": 272,
"Name": "Juniper",
"Genus": "Juniperus",
"PlantType": "Tree",
},
{
"LGID": 346,
"Name": "Grasses",
"Genus": "Grasses",
"PlantType": "Grass",
},
{
"LGID": 63,
"Name": "Chenopods",
"Genus": "Chenopods",
"PlantType": "Ragweed",
},
],
"Period": "0001-01-01T00:00:00",
"Type": "Tomorrow",
"Index": 6.3,
},
],
"DisplayLocation": REDACTED,
},
},
"allergy_outlook": {
"Market": REDACTED,
"ZIP": REDACTED,
"TrendID": 4,
"Trend": "subsiding",
"Outlook": "The amount of pollen in the air for Wednesday...",
"Season": "Tree",
},
"asthma_average_forecasted": {
"Type": "asthma",
"ForecastDate": "2018-10-28T00:00:00-04:00",
"Location": {
"ZIP": REDACTED,
"City": REDACTED,
"State": REDACTED,
"periods": [
{
"Period": "2018-10-28T05:45:01.45",
"Index": 4.5,
"Idx": "4.5",
},
{
"Period": "2018-10-29T05:45:01.45",
"Index": 4.7,
"Idx": "4.7",
},
{"Period": "2018-10-30T05:45:01.45", "Index": 5, "Idx": "5.0"},
{
"Period": "2018-10-31T05:45:01.45",
"Index": 5.2,
"Idx": "5.2",
},
{
"Period": "2018-11-01T05:45:01.45",
"Index": 5.5,
"Idx": "5.5",
},
],
"DisplayLocation": REDACTED,
},
},
"asthma_index": {
"Type": "asthma",
"ForecastDate": "2018-10-29T00:00:00-04:00",
"Location": {
"ZIP": REDACTED,
"City": REDACTED,
"State": REDACTED,
"periods": [
{
"Triggers": [
{
"LGID": 1,
"Name": "OZONE",
"PPM": 42,
"Description": (
"Ozone (O3) is a odorless, colorless ...."
),
},
{
"LGID": 1,
"Name": "PM2.5",
"PPM": 30,
"Description": "Fine particles (PM2.5) are 2.5 ...",
},
{
"LGID": 1,
"Name": "PM10",
"PPM": 19,
"Description": (
"Coarse dust particles (PM10) are 2.5 ..."
),
},
],
"Period": "0001-01-01T00:00:00",
"Type": "Yesterday",
"Index": 4.1,
"Idx": "4.1",
},
{
"Triggers": [
{
"LGID": 3,
"Name": "PM2.5",
"PPM": 105,
"Description": "Fine particles (PM2.5) are 2.5 ...",
},
{
"LGID": 2,
"Name": "PM10",
"PPM": 65,
"Description": (
"Coarse dust particles (PM10) are 2.5 ..."
),
},
{
"LGID": 1,
"Name": "OZONE",
"PPM": 42,
"Description": (
"Ozone (O3) is a odorless, colorless ..."
),
},
],
"Period": "0001-01-01T00:00:00",
"Type": "Today",
"Index": 4.5,
"Idx": "4.5",
},
{
"Triggers": [],
"Period": "0001-01-01T00:00:00",
"Type": "Tomorrow",
"Index": 4.6,
"Idx": "4.6",
},
],
"DisplayLocation": REDACTED,
},
},
"disease_average_forecasted": {
"Type": "cold",
"ForecastDate": "2018-06-12T00:00:00-04:00",
"Location": {
"ZIP": REDACTED,
"City": REDACTED,
"State": REDACTED,
"periods": [
{"Period": "2018-06-12T05:13:51.817", "Index": 2.4},
{"Period": "2018-06-13T05:13:51.817", "Index": 2.5},
{"Period": "2018-06-14T05:13:51.817", "Index": 2.5},
{"Period": "2018-06-15T05:13:51.817", "Index": 2.5},
],
"DisplayLocation": REDACTED,
},
},
"disease_index": {
"ForecastDate": "2019-04-07T00:00:00-04:00",
"Location": {
"City": REDACTED,
"DisplayLocation": REDACTED,
"State": REDACTED,
"ZIP": REDACTED,
"periods": [
{
"Idx": "6.8",
"Index": 6.8,
"Period": "2019-04-06T00:00:00",
"Triggers": [
{
"Description": "Influenza",
"Idx": "3.1",
"Index": 3.1,
"Name": "Flu",
},
{
"Description": "High Fever",
"Idx": "6.2",
"Index": 6.2,
"Name": "Fever",
},
{
"Description": "Strep & Sore throat",
"Idx": "5.2",
"Index": 5.2,
"Name": "Strep",
},
{
"Description": "Cough",
"Idx": "7.8",
"Index": 7.8,
"Name": "Cough",
},
],
"Type": "Yesterday",
},
{
"Idx": "6.7",
"Index": 6.7,
"Period": "2019-04-07T03:52:58",
"Triggers": [
{
"Description": "Influenza",
"Idx": "3.1",
"Index": 3.1,
"Name": "Flu",
},
{
"Description": "High Fever",
"Idx": "5.9",
"Index": 5.9,
"Name": "Fever",
},
{
"Description": "Strep & Sore throat",
"Idx": "5.1",
"Index": 5.1,
"Name": "Strep",
},
{
"Description": "Cough",
"Idx": "7.7",
"Index": 7.7,
"Name": "Cough",
},
],
"Type": "Today",
},
],
},
"Type": "cold",
},
},
}
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)