Skip to content

Commit

Permalink
Remove default use of google calendars yaml file in tests (home-assis…
Browse files Browse the repository at this point in the history
…tant#73621)

Remove default use of
 google_calendars.yaml in tests
  • Loading branch information
allenporter authored Jun 17, 2022
1 parent e304784 commit ea21a36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/components/google/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand Down
19 changes: 12 additions & 7 deletions tests/components/google/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
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",
Expand Down Expand Up @@ -58,7 +63,6 @@
@pytest.fixture(autouse=True)
def mock_test_setup(
hass,
mock_calendars_yaml,
test_api_calendar,
mock_calendars_list,
config_entry,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -551,6 +555,7 @@ async def get(method, url, data):
async def test_opaque_event(
hass,
hass_client,
mock_calendars_yaml,
mock_events_list_items,
component_setup,
transparency,
Expand All @@ -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
Expand Down
11 changes: 3 additions & 8 deletions tests/components/google/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ea21a36

Please sign in to comment.