Clean and fix google calendar tests (#23608)
* Clean and fix google calendar tests * Extract test calendar constant for google test * Rewrite google calendar tests * Clean and fix google calendar tests * Clean and fix google component tests * Add google conftest * Skip flaky google calendar test * Fix google calendar bug * Fix yield fixture * Set fixture names to avoid lint warning * Fix yield fixture
This commit is contained in:
1 parent
e24d56aa5b
commit
b9fda078a4
4 files changed
+376
-477
No files matched your search
@@ -72,7 +72,7 @@ class GoogleCalendarData:
|
||||
service = self.calendar_service.get()
|
||||
except ServerNotFoundError:
|
||||
_LOGGER.warning("Unable to connect to Google, using cached data")
|
||||
return False
|
||||
return None, None
|
||||
params = dict(DEFAULT_GOOGLE_SEARCH_PARAMS)
|
||||
params['calendarId'] = self.calendar_id
|
||||
if self.max_results:
|
||||
@@ -84,12 +84,16 @@ class GoogleCalendarData:
|
||||
|
||||
async def async_get_events(self, hass, start_date, end_date):
|
||||
"""Get all events in a specific time frame."""
|
||||
service, params = await hass.async_add_job(self._prepare_query)
|
||||
service, params = await hass.async_add_executor_job(
|
||||
self._prepare_query)
|
||||
if service is None:
|
||||
return
|
||||
params['timeMin'] = start_date.isoformat('T')
|
||||
params['timeMax'] = end_date.isoformat('T')
|
||||
|
||||
events = await hass.async_add_job(service.events)
|
||||
result = await hass.async_add_job(events.list(**params).execute)
|
||||
events = await hass.async_add_executor_job(service.events)
|
||||
result = await hass.async_add_executor_job(
|
||||
events.list(**params).execute)
|
||||
|
||||
items = result.get('items', [])
|
||||
event_list = []
|
||||
@@ -106,6 +110,8 @@ class GoogleCalendarData:
|
||||
def update(self):
|
||||
"""Get the latest data."""
|
||||
service, params = self._prepare_query()
|
||||
if service is None:
|
||||
return False
|
||||
params['timeMin'] = dt.now().isoformat('T')
|
||||
|
||||
events = service.events()
|
||||
|
||||
Reference in new issue
Block a user