Remove default use of google calendars yaml file in tests (#73621)

Remove default use of
 google_calendars.yaml in tests
This commit is contained in:
Allen Porter 2022-06-17 00:04:41 -07:00 committed by GitHub
parent e30478457b
commit ea21a36e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View File

@ -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( def mock_calendars_yaml(
hass: HomeAssistant, hass: HomeAssistant,
calendars_config: list[dict[str, Any]], calendars_config: list[dict[str, Any]],

View File

@ -17,13 +17,18 @@ from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.helpers.template import DATE_STR_FORMAT from homeassistant.helpers.template import DATE_STR_FORMAT
import homeassistant.util.dt as dt_util 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.common import async_fire_time_changed
from tests.test_util.aiohttp import AiohttpClientMockResponse from tests.test_util.aiohttp import AiohttpClientMockResponse
TEST_ENTITY = TEST_YAML_ENTITY TEST_ENTITY = TEST_API_ENTITY
TEST_ENTITY_NAME = TEST_YAML_ENTITY_NAME TEST_ENTITY_NAME = TEST_API_ENTITY_NAME
TEST_EVENT = { TEST_EVENT = {
"summary": "Test All Day Event", "summary": "Test All Day Event",
@ -58,7 +63,6 @@ TEST_EVENT = {
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_test_setup( def mock_test_setup(
hass, hass,
mock_calendars_yaml,
test_api_calendar, test_api_calendar,
mock_calendars_list, mock_calendars_list,
config_entry, 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().""" """Return a calendar API to return events created by upcoming()."""
now = dt_util.now() now = dt_util.now()
start = (now - datetime.timedelta(minutes=60)).isoformat() start = (now - datetime.timedelta(minutes=60)).isoformat()
end = (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( async def test_all_day_event(
@ -551,6 +555,7 @@ async def test_http_api_event_paging(
async def test_opaque_event( async def test_opaque_event(
hass, hass,
hass_client, hass_client,
mock_calendars_yaml,
mock_events_list_items, mock_events_list_items,
component_setup, component_setup,
transparency, transparency,
@ -566,7 +571,7 @@ async def test_opaque_event(
assert await component_setup() assert await component_setup()
client = await hass_client() 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 assert response.status == HTTPStatus.OK
events = await response.json() events = await response.json()
assert (len(events) > 0) == expect_visible_event assert (len(events) > 0) == expect_visible_event

View File

@ -74,7 +74,7 @@ def setup_config_entry(
( (
SERVICE_CREATE_EVENT, SERVICE_CREATE_EVENT,
{}, {},
{"entity_id": TEST_YAML_ENTITY}, {"entity_id": TEST_API_ENTITY},
), ),
], ],
ids=("add_event", "create_event"), ids=("add_event", "create_event"),
@ -245,13 +245,12 @@ async def test_found_calendar_from_api(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"calendars_config,google_config,config_entry_options", "google_config,config_entry_options",
[([], {}, {CONF_CALENDAR_ACCESS: "read_write"})], [({}, {CONF_CALENDAR_ACCESS: "read_write"})],
) )
async def test_load_application_credentials( async def test_load_application_credentials(
hass: HomeAssistant, hass: HomeAssistant,
component_setup: ComponentSetup, component_setup: ComponentSetup,
mock_calendars_yaml: None,
mock_calendars_list: ApiResult, mock_calendars_list: ApiResult,
test_api_calendar: dict[str, Any], test_api_calendar: dict[str, Any],
mock_events_list: ApiResult, mock_events_list: ApiResult,
@ -464,7 +463,6 @@ async def test_add_event_invalid_params(
component_setup: ComponentSetup, component_setup: ComponentSetup,
mock_calendars_list: ApiResult, mock_calendars_list: ApiResult,
test_api_calendar: dict[str, Any], test_api_calendar: dict[str, Any],
mock_calendars_yaml: None,
mock_events_list: ApiResult, mock_events_list: ApiResult,
setup_config_entry: MockConfigEntry, setup_config_entry: MockConfigEntry,
add_event_call_service: Callable[dict[str, Any], Awaitable[None]], 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_calendars_list: ApiResult,
mock_insert_event: Callable[[..., dict[str, Any]], None], mock_insert_event: Callable[[..., dict[str, Any]], None],
test_api_calendar: dict[str, Any], test_api_calendar: dict[str, Any],
mock_calendars_yaml: None,
mock_events_list: ApiResult, mock_events_list: ApiResult,
date_fields: dict[str, Any], date_fields: dict[str, Any],
start_timedelta: datetime.timedelta, start_timedelta: datetime.timedelta,
@ -544,7 +541,6 @@ async def test_add_event_date(
mock_calendars_list: ApiResult, mock_calendars_list: ApiResult,
test_api_calendar: dict[str, Any], test_api_calendar: dict[str, Any],
mock_insert_event: Callable[[str, dict[str, Any]], None], mock_insert_event: Callable[[str, dict[str, Any]], None],
mock_calendars_yaml: None,
mock_events_list: ApiResult, mock_events_list: ApiResult,
setup_config_entry: MockConfigEntry, setup_config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker, aioclient_mock: AiohttpClientMocker,
@ -586,7 +582,6 @@ async def test_add_event_date_time(
mock_calendars_list: ApiResult, mock_calendars_list: ApiResult,
mock_insert_event: Callable[[str, dict[str, Any]], None], mock_insert_event: Callable[[str, dict[str, Any]], None],
test_api_calendar: dict[str, Any], test_api_calendar: dict[str, Any],
mock_calendars_yaml: None,
mock_events_list: ApiResult, mock_events_list: ApiResult,
setup_config_entry: MockConfigEntry, setup_config_entry: MockConfigEntry,
aioclient_mock: AiohttpClientMocker, aioclient_mock: AiohttpClientMocker,