mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
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:
parent
e30478457b
commit
ea21a36e52
@ -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]],
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user