Commit Graph

46 Commits (9e53bca45212e3db8c4117f16471c468ea863c9c)

Author SHA1 Message Date
Allen Porter 93eac97983
Relax the constraint that events must have a consistent timezone for start/end (#91788) 2023-04-21 10:25:52 -04:00
Allen Porter 14b95ffe3a
Relax calendar event validation to allow existing zero duration events (#91129)
Relax event valudation to allow existing zero duration events
2023-04-10 10:04:42 -04:00
Allen Porter 23af02b941
Make location optional in google calendar create service (#91061) 2023-04-08 22:40:39 -04:00
Luca Angemi 6d8eaa0bee
Add location field to calendar create_event service supported by Google Calendar and Local Calendar (#90098)
* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update calendar.py

* Update calendar.py

* Update services.yaml

* Update services.yaml

* Update calendar.py

* Update calendar.py

* Update __init__.py

* Update services.yaml

* Update services.yaml

* Update test_calendar.py

* Update test_init.py

* Update test_init.py

* Update test_init.py

* Update test_init.py

* Update __init__.py

* Update const.py

* Address changes to service.yaml

* Address changes to service.yaml

* Update test_calendar.py

* Update test_calendar.py

* Update test_calendar.py

* Update conftest.py

* Update conftest.py

* Update calendar.py

* Update __init__.py
2023-03-25 09:43:49 -07:00
epenet 71dc98a39c
Improve hass_ws_client type hint in tests (#89703) 2023-03-14 16:31:40 +01:00
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet b68f502769
Add type hints to integration tests (part 7) (#87980) 2023-02-13 09:53:09 +01:00
Allen Porter 2049993941
Check google calendar API scope to determine if write access is enabled (#84749)
* Check google calendar API scope to determine if write access is enabled

* Add API scope for calendar service for creating events
2022-12-29 11:00:31 +01:00
Allen Porter f9779d3e97
Bump gcal-sync to 4.1.0 (#84474)
* Bump gcal-sync to 4.1.0

* Update test with UNTIL improvements
2022-12-22 23:28:12 -05:00
Allen Porter d41fe01736
Don't allow google calendar create/delete for yaml/search calendars (#83604)
* Update tests/components/google/test_calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Don't allow google calendar create/delete for yaml/search calendars

* Revert incorrect docstring update

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-21 07:36:37 -08:00
Allen Porter 4e1b399efd
Fix google calendar recurrence rule create and view (#84330)
* Fix bug in google calendar recurrence rule handling

* Convert multiline ternary operator expressions to if block
2022-12-21 07:36:20 -08:00
Allen Porter 5d1ca73a34
Add create and delete for Google Calendar events (#83034)
* Add Google Calendar create/delete support

Includes editing for recurring events

* Fix default calendar access role

* Formatting improvements

* Address other details that have changed due to local sync

* Update tests/components/google/test_calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/google/test_calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/google/test_calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Increase test coverage

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-01 21:39:58 +01:00
Allen Porter e6d1a4a422
Revert google calendar back to old API for free/busy readers (#81894)
* Revert google calendar back to old API for free/busy readers

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-11-10 08:31:28 -08:00
Allen Porter 0941ed076c
Cleanup unnecessary google calendar test fixtures (#81876) 2022-11-09 20:59:00 +01:00
Allen Porter ba8fd6b01e
Google calendar test cleanup, avoiding dupe config entry setup (#81256) 2022-10-30 23:07:10 +01:00
Allen Porter 0e2bea038d
Update Google Calendar to synchronize calendar events efficiently (#80925)
* Sync google calendar and serve from local storage

Update to use new gcal_sync APIs
Update google calendar filter logic
Remove storage on config entry removal
Make timeline queries timezone aware
Do not block startup while syncing

* Minor readability tweaks

* Remove unnecessary args to async_add_entities

* Change how task is created on startup

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Revert min time between updates

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-10-26 07:57:49 -07:00
Allen Porter e71bd2c20b
Fix google calendar test to match API behavior (#80436) 2022-10-16 14:45:57 -04:00
Allen Porter a7f33535c7
Fix google calendar event transparency filter (#80438) 2022-10-16 14:45:27 -04:00
Allen Porter f4e61eff18
Add update coordinator for google calendar (#74690)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-10 21:24:52 -07:00
Allen Porter 6f9fcdff99
Improve calendar error handling to match best practices (#74891) 2022-07-10 10:04:57 -07:00
Allen Porter a4c6cd2fbe
Cleanup Google Calendar unused test fixtures (#74353) 2022-07-03 17:05:38 +02:00
Allen Porter d399815bea
Allow multiple google calendar config entries (#73715)
* Support multiple config entries at once

* Add test coverage for multiple config entries

* Add support for multiple config entries to google config flow

* Clear hass.data when unloading config entry

* Make google config flow defensive against reuse of the same account

* Assign existing google config entries a unique id

* Migrate entities to new unique id format

* Support muliple accounts per oauth client id

* Fix mypy typing errors

* Hard fail to keep state consistent, removing graceful degredation

* Remove invalid entity regsitry entries
2022-06-21 06:42:41 -07:00
Allen Porter ea21a36e52
Remove default use of google calendars yaml file in tests (#73621)
Remove default use of
 google_calendars.yaml in tests
2022-06-17 09:04:41 +02:00
Allen Porter 71bc650ac7
Stop updating google_calendars.yaml if it does not already exist (#72340)
* Stop updating google_calendars.yaml if it does not already exist

* Add additional test coverage to make CI pass

* Add test for no updates to google_calendar.yaml

* Add parameter to test for expecting write calls

* Missing call argument

* Remove conditional and replace with inline assert
2022-05-25 08:59:27 +02:00
Allen Porter 8a13c6744a
Bump gcal_sync to 0.6.2 and switch to google calendar async iterator api (#70616)
* Switch to google calendar async iterator api

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add test coverage for paging through results

* Bump gcal_sync to 0.6.1

* Bump gcal-sync 0.6.2

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-27 07:22:15 -07:00
Allen Porter 0e0c0ce22b
Move google calendar integration to aiohttp (#70173)
* Use new aiohttp based google client library in gcal_sync.

* Use base url in tests for shorter string

* Remove unnecessary line of code

* Jump to gcal-sync-0.4.1

* Update tests/components/google/conftest.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update to gcal_sync 0.5.0 incorporating PR feedback

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-20 20:18:24 -07:00
Allen Porter 36bb947cdf
Fix bug in google calendar offset calculation (#70024)
Move the offset reached computation outside of the update method so that it is
computed when state updates occur rather than when data refreshes happen (which
are throttled and happen at most every 15 minutes).

Issue #69892
2022-04-13 19:04:59 -07:00
Allen Porter 10a1b1f734
Gracefully handle empty summary in google calendar (#69520)
Gracefully handle empty summary in google calendar matching the old behavior
before some code cleanup.
2022-04-07 08:26:07 +02:00
Allen Porter 609c6ef5d4
Add test coverage for google calendar event response format (#68767)
Add test coverage for the calendar event response format as I am about to do some
refactoring and simplification. Notably, each calendar implementation uses a slightly different
API response, and this is codifying that.
2022-03-28 18:05:02 +02:00
Allen Porter 7876ffe9e3
Update google calendar integration with a config flow (#68010)
* Convert google calendar to config flow and async

* Call correct exchange method

* Fix async method and reduce unnecessary diffs

* Wording improvements

* Reduce unnecessary diffs

* Run load/update config from executor

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Remove unnecessary updating of unexpected multiple config entries.

* Remove unnecessary unique_id checks

* Improve readability with comments about device code expiration

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/google/calendar.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/google/api.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add comment for when code is none on timeout

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-03-15 07:51:02 +01:00
Allen Porter 8adcd10f55
Make google calendar loading API centric, not loading from yaml (#67722)
* Make google calendar loading API centric, not loading from yaml

Update the behavior for google calendar to focus on loading calendars based on the
API and using the yaml configuration to override behavior. The old behavior was
to first load from yaml, then also load from the API, which is atypical.

This is pulled out from a larger change to rewrite calendar using async and config
flows.

Tests needed to be updated to reflect the new API centric behavior, and changing
the API call ordering required changing tests that exercise failures.

* Update to use async_fire_time_changed to invoke updates
2022-03-08 21:56:49 +01:00
Allen Porter 57ffc65af2
Improve google calendar test quality and share setup (#67441)
* Improve google calendar test quality and share setup

Improve google calendar test quality by exercising different combinations of
cases and new coverage. The existing test cases do achieve very high coverage,
however some of the subtle interactions between the components are not as well
exercised, which is needed when we start changing how the internal code is
structured moving to async or to config entries.

Ipmrovement include:
- Exercising additional cases around different types of configuration parameters
  that control how calendars are tracked or not tracked. The tracking can be
  configured in google_calendars.yaml, or by defaults set in configuration.yaml
  for new calendars.
- Share even more test setup, used when exercising the above different scenarios
- Add new test cases for event creation.
- Improve test readability by making more clear the differences between tests
  exercising yaml and API test calendars. The data types are now more clearly
  separated in the two cases, as well as the entity names created in the two
  cases.

* Undo some diffs for readability

* Improve pydoc readability

* Improve pydoc readability

* Incorporate improvements from Martin

* Make test parameters a State instance

* Update test naming to be more correct

* Fix flake8 errors
2022-03-03 23:12:24 -08:00
Allen Porter 466f1686e4
Cleanup google calendar shared test fixtures (#67343) 2022-02-27 19:58:00 +01:00
Allen Porter deda9e38e4
Simplify google calendar API interactions (#67319)
* Simplify google calendar APIs and tests

* Simplify authentication logic at startup

* Improve readability of diffs

* Reduce diffs

* Simplify api datetime logic

* Remove duplicate test fixtures added in prior commit

* Remove duplicate event filter calls

* Fix event list argument names

* More improvements found from additional testing

* Remove unnecessary variables in create event call
2022-02-26 16:19:45 -08:00
Allen Porter 0e74184e4f
Simplify google calendar authentication setup (#67314)
Simplify google calendar authentication to combine some of the cases together, and reduce unecessarily checks. Make the
tests share common authentication setup and reduce use of mocks by introducing a fake for holding on to credentials.
This makes future refactoring simpler, so we don't have to care as much about the interactions with the credentials
storage.
2022-02-26 15:17:02 -08:00
Allen Porter 88ed2f3b3e
Improve google calendar test coverage to 97% (#65223)
* Improve google calendar test coverage to 97%

* Remove commented out code.

* Remove unnecessary (flaky) checks for token file persistence

* Remove mock code assertions

* Add debug logging to google calendar integration

* Increase alarm time to polling code to reduce flakes

* Setup every test in their own configuration directory

* Mock out filesystem calls to avoid disk dependencies

Update scope checking code to use Storage object rather than text file matching

* Update tests to check entity states when integration is loaded

* Mock out google service in multiple locations

* Update homeassistant/components/google/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/google/__init__.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-02-01 03:14:49 +01:00
Marc Mueller d057850971
Update typing - collections.abc (3) (#63947) 2022-01-12 08:04:17 +01:00
Allen Porter 23277181ca
Increase test coverage for google calendar (#62648)
* Increase test coverage for google calendar

Update tests to exercise the API responses, getting test coverage
to 97% for calendar.py

----------- coverage: platform linux, python 3.9.6-final-0 -----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
homeassistant/components/google/__init__.py     193     84    56%   92, 163-228, 238, 244-247, 254-262, 274, 298-299, 305-347, 387-392, 416-430, 435-437
homeassistant/components/google/calendar.py     122      4    97%   41, 45, 51, 135
---------------------------------------------------------------------------
TOTAL                                           315     88    72%

* Revert conftest changes

* Update typing errors found on CI

* Update python3.8 typing imports

* Remove commented out code
2021-12-23 07:31:56 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Paulus Schoutsen 2af984917e
Use asynctest-mock in most places (#35109)
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
springstan ad102b3840
Use f-strings in integrations starting with "F"and"G" (#32150)
* Use f-strings in integrations starting with F

* Use f-strings in tests for integrations starting with F

* Use f-strings in integrations starting with G

* Use f-strings in tests for integrations starting with G

* Fix pylint error

* Fix broken test
2020-02-24 17:54:20 -08:00
Bas Nijholt d58e6e924a Sort imports according to PEP8 for components starting with "G" (#29767) 2019-12-09 14:17:36 +01:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Martin Hjelmare 177f5a35ae Rewrite calendar component (#24950)
* Correct google calendar test name

* Rewrite calendar component

* Save component in hass.data.
* Rename device_state_attributes to state_attributes.
* Remove offset attribute from base state_attributes.
* Extract offset helpers to calendar component.
* Clean imports.
* Remove stale constants.
* Remove name and add async_get_events.
* Add normalize_event helper function. Copied from #21495.
* Add event property to base entity.
* Use event property for calendar state.
* Ensure event start and end.
* Remove entity init.
* Add comment about event data class.
* Temporary keep old start and end datetime format.

* Convert demo calendar

* Convert google calendar

* Convert google calendar.
* Clean up google component.
* Keep offset feature by using offset helpers.

* Convert caldav calendar

* Clean up caldav calendar.
* Update caldav cal on addition.
* Bring back offset to caldav calendar.
* Copy caldav event on update.

* Convert todoist calendar
2019-07-10 20:59:37 -07:00
Martin Hjelmare b9fda078a4
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
2019-05-05 18:38:55 +02:00
Paulus Schoutsen e2d3c27e85
Embed all platforms into components (#20677)
* Consolidate all components with platforms

* Organize tests

* Fix more tests

* Fix Verisure tests

* one final test fix

* Add change

* Fix coverage
2019-02-02 07:13:16 -08:00