From ea21a36e52a3a157bf86c75de13c8e78ec006ea2 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 17 Jun 2022 00:04:41 -0700 Subject: [PATCH] Remove default use of google calendars yaml file in tests (#73621) Remove default use of google_calendars.yaml in tests --- tests/components/google/conftest.py | 2 +- tests/components/google/test_calendar.py | 19 ++++++++++++------- tests/components/google/test_init.py | 11 +++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/components/google/conftest.py b/tests/components/google/conftest.py index 68176493445..27fb6c993ff 100644 --- a/tests/components/google/conftest.py +++ b/tests/components/google/conftest.py @@ -99,7 +99,7 @@ def calendars_config(calendars_config_entity: dict[str, Any]) -> list[dict[str, ] -@pytest.fixture(autouse=True) +@pytest.fixture def mock_calendars_yaml( hass: HomeAssistant, calendars_config: list[dict[str, Any]], diff --git a/tests/components/google/test_calendar.py b/tests/components/google/test_calendar.py index 794065ca09a..85711014e72 100644 --- a/tests/components/google/test_calendar.py +++ b/tests/components/google/test_calendar.py @@ -17,13 +17,18 @@ from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.helpers.template import DATE_STR_FORMAT import homeassistant.util.dt as dt_util -from .conftest import CALENDAR_ID, TEST_YAML_ENTITY, TEST_YAML_ENTITY_NAME +from .conftest import ( + CALENDAR_ID, + TEST_API_ENTITY, + TEST_API_ENTITY_NAME, + TEST_YAML_ENTITY, +) from tests.common import async_fire_time_changed from tests.test_util.aiohttp import AiohttpClientMockResponse -TEST_ENTITY = TEST_YAML_ENTITY -TEST_ENTITY_NAME = TEST_YAML_ENTITY_NAME +TEST_ENTITY = TEST_API_ENTITY +TEST_ENTITY_NAME = TEST_API_ENTITY_NAME TEST_EVENT = { "summary": "Test All Day Event", @@ -58,7 +63,6 @@ TEST_EVENT = { @pytest.fixture(autouse=True) def mock_test_setup( hass, - mock_calendars_yaml, test_api_calendar, mock_calendars_list, config_entry, @@ -87,12 +91,12 @@ def upcoming_date() -> dict[str, Any]: } -def upcoming_event_url() -> str: +def upcoming_event_url(entity: str = TEST_ENTITY) -> str: """Return a calendar API to return events created by upcoming().""" now = dt_util.now() start = (now - datetime.timedelta(minutes=60)).isoformat() end = (now + datetime.timedelta(minutes=60)).isoformat() - return f"/api/calendars/{TEST_ENTITY}?start={urllib.parse.quote(start)}&end={urllib.parse.quote(end)}" + return f"/api/calendars/{entity}?start={urllib.parse.quote(start)}&end={urllib.parse.quote(end)}" async def test_all_day_event( @@ -551,6 +555,7 @@ async def test_http_api_event_paging( async def test_opaque_event( hass, hass_client, + mock_calendars_yaml, mock_events_list_items, component_setup, transparency, @@ -566,7 +571,7 @@ async def test_opaque_event( assert await component_setup() client = await hass_client() - response = await client.get(upcoming_event_url()) + response = await client.get(upcoming_event_url(TEST_YAML_ENTITY)) assert response.status == HTTPStatus.OK events = await response.json() assert (len(events) > 0) == expect_visible_event diff --git a/tests/components/google/test_init.py b/tests/components/google/test_init.py index b2a81b47718..f9391a82b6a 100644 --- a/tests/components/google/test_init.py +++ b/tests/components/google/test_init.py @@ -74,7 +74,7 @@ def setup_config_entry( ( SERVICE_CREATE_EVENT, {}, - {"entity_id": TEST_YAML_ENTITY}, + {"entity_id": TEST_API_ENTITY}, ), ], ids=("add_event", "create_event"), @@ -245,13 +245,12 @@ async def test_found_calendar_from_api( @pytest.mark.parametrize( - "calendars_config,google_config,config_entry_options", - [([], {}, {CONF_CALENDAR_ACCESS: "read_write"})], + "google_config,config_entry_options", + [({}, {CONF_CALENDAR_ACCESS: "read_write"})], ) async def test_load_application_credentials( hass: HomeAssistant, component_setup: ComponentSetup, - mock_calendars_yaml: None, mock_calendars_list: ApiResult, test_api_calendar: dict[str, Any], mock_events_list: ApiResult, @@ -464,7 +463,6 @@ async def test_add_event_invalid_params( component_setup: ComponentSetup, mock_calendars_list: ApiResult, test_api_calendar: dict[str, Any], - mock_calendars_yaml: None, mock_events_list: ApiResult, setup_config_entry: MockConfigEntry, add_event_call_service: Callable[dict[str, Any], Awaitable[None]], @@ -504,7 +502,6 @@ async def test_add_event_date_in_x( mock_calendars_list: ApiResult, mock_insert_event: Callable[[..., dict[str, Any]], None], test_api_calendar: dict[str, Any], - mock_calendars_yaml: None, mock_events_list: ApiResult, date_fields: dict[str, Any], start_timedelta: datetime.timedelta, @@ -544,7 +541,6 @@ async def test_add_event_date( mock_calendars_list: ApiResult, test_api_calendar: dict[str, Any], mock_insert_event: Callable[[str, dict[str, Any]], None], - mock_calendars_yaml: None, mock_events_list: ApiResult, setup_config_entry: MockConfigEntry, aioclient_mock: AiohttpClientMocker, @@ -586,7 +582,6 @@ async def test_add_event_date_time( mock_calendars_list: ApiResult, mock_insert_event: Callable[[str, dict[str, Any]], None], test_api_calendar: dict[str, Any], - mock_calendars_yaml: None, mock_events_list: ApiResult, setup_config_entry: MockConfigEntry, aioclient_mock: AiohttpClientMocker,