Commit Graph

83 Commits

Author SHA1 Message Date
Abílio Costa
d87c963db5 Prevent zero interval in Calendar get_events service (#139378)
* Prevent zero interval in Calendar get_events service

* Fix holiday calendar tests

* Remove redundant entity_id

* Use translation for exception

* Replace check with voluptuous validator

* Revert strings.xml
2025-03-04 09:52:29 +01:00
Erik Montnemery
428cc1a951 Update signature of platforms' async_setup_entry in tests (#138271) 2025-02-11 13:17:39 +01:00
epenet
7b1b229718 Standardize homeassistant imports in component tests (a-l) (#136806) 2025-01-29 10:00:45 +01:00
Jan Bouwhuis
3aae9b629f Add exception translation for entity action not supported (#131956) 2024-12-01 16:53:06 +01:00
Joost Lekkerkerker
e8d7eb05ae Delete unused snapshots (#123656)
* Delete unused snapshots

* Delete unused snapshots
2024-08-12 13:28:09 +02:00
epenet
5d809f88ba Improve type hints in calendar tests (#121654) 2024-07-10 09:12:56 +02:00
Marc Mueller
2f0dd6f704 Import Generator from collections.abc (2) (#120915) 2024-07-01 11:58:49 +02:00
G Johansson
9c5879656c Remove legacy list event calendar service (#118663) 2024-06-21 11:18:51 +02:00
Marc Mueller
279483ddb0 Import Generator from typing_extensions (2) (#118989) 2024-06-06 17:24:22 +02:00
J. Nick Koston
ed0568c655 Ensure config entries are not unloaded while their platforms are setting up (#118767)
* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* Report non-awaited/non-locked config entry platform forwards

Its currently possible for config entries to be reloaded while their platforms
are being forwarded if platform forwards are not awaited or done after the
config entry is setup since the lock will not be held in this case.

In https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards
we advised to await platform forwards to ensure this does not happen, however
for sleeping devices and late discovered devices, platform forwards may happen
later.

If config platform forwards are happening during setup, they should be awaited

If config entry platform forwards are not happening during setup, instead
async_late_forward_entry_setups should be used which will hold the lock to
prevent the config entry from being unloaded while its platforms are being
setup

* run with error on to find them

* cert_exp, hold lock

* cert_exp, hold lock

* shelly async_late_forward_entry_setups

* compact

* compact

* found another

* patch up mobileapp

* patch up hue tests

* patch up smartthings

* fix mqtt

* fix esphome

* zwave_js

* mqtt

* rework

* fixes

* fix mocking

* fix mocking

* do not call async_forward_entry_setup directly

* docstrings

* docstrings

* docstrings

* add comments

* doc strings

* fixed all in core, turn off strict

* coverage

* coverage

* missing

* coverage
2024-06-04 21:34:39 -04:00
epenet
e488f9b87f Rename calls fixture in calendar tests (#118353) 2024-05-29 09:24:36 +02:00
epenet
44f715bd02 Use issue_registry fixture in component tests (#118041) 2024-05-24 15:54:20 +02:00
J. Nick Koston
5a609c34bb Fix blocking I/O in the event loop when loading timezones (#117721) 2024-05-20 11:06:03 +02:00
Sid
d5f883fbf0 Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Marc Mueller
81c34ac952 Fix spelling [docstrings + comments] (#114168) 2024-03-25 11:33:00 +01:00
Marc Mueller
38adfbf1a3 Add empty line after module docstring [tests a-e] (#112708) 2024-03-08 08:50:25 -05:00
Allen Porter
1eac7bcbec Fix calendar trigger to survive config entry reloads (#111334)
* Fix calendar trigger to survive config entry reloads

* Apply suggestions from code review

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-02-29 03:45:51 +01:00
Allen Porter
1069693292 Update calendar tests to use mock entities instead of demo platform (#105317)
* Update calendar tests to use mock entities instead of demo platform

* Add Generator type to fixture

* Fix generator syntax

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-01-30 06:36:14 +01:00
Kevin Stillhammer
51385dcaab Deprecate calendar.list_events (#102481)
* deprecate calendar.list_events

* rename events to get_events

* raise issue for use of deprecated service

* Make issue fixable

* Add fix_flow

* Add service translation/yaml
2023-11-19 07:12:43 -08:00
Kevin Stillhammer
d7e195ba40 Use snapshots in calendar tests (#102299) 2023-10-20 15:14:31 +02:00
Ville Skyttä
3094991236 Upgrade ruff to 0.0.285 (#98647) 2023-08-19 08:17:17 -04:00
Allen Porter
26f2fabd85 Fix timezones used in list events (#95804)
* Fix timezones used in list events

* Add additional tests that catch floating vs timezone datetime comparisons
2023-07-05 08:25:03 +02:00
Allen Porter
2f73be0e50 Ensure that calendar output values are json types (#95797) 2023-07-03 12:05:02 -07:00
Allen Porter
7252c33df8 Limit fields returned for the list events service (#95506)
* Limit fields returned for the list events service

* Update websocket tests and fix bugs in response fields

* Omit 'None' fields in the list events response
2023-06-29 13:25:25 -04:00
Allen Porter
b9b5fe6be8 Add service response data for listing calendar events (#94759)
* Add service response data for listing calendar events

Add the capability of response data for for the entity component.

* Rename input arguments and add service description

* Improve list events to be more user friendly

Allow the end date to be determined based on a relative time duration. Make the start time optional and set to "now". Add additional test coverage. Update demo calendar to actually perform date range checks.

* Wrap docstrings properly.

* Increase test coverage

* Update to use new API calls

* Readability improvements

* Wrap docstrings

* Require at least one of end or duration

* Check for multiple entity matches earlier in the request

* Update documentation strings
2023-06-23 23:34:34 -04:00
Erik Montnemery
9a3077d64a Always setup demo platforms with device support from config entry (#94586)
* Always setup demo platforms with device support from config entry

* Adjust test fixutres

* Update tests depending on the demo integration
2023-06-14 16:50:35 +02:00
Erik Montnemery
0126cfa9d9 Allow exposing any entity to the default conversation agent (#92398)
* Allow exposing any entity to the default conversation agent

* Tweak

* Fix race, update tests

* Update tests
2023-05-03 09:45:54 -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
J. Nick Koston
d0d4ab6056 Require a list of entity ids when fetching history (#90992) 2023-04-08 16:14:44 -10:00
epenet
60692bcfdb Fix lingering timers in calendar tests (#90845) 2023-04-05 20:46:05 -04:00
epenet
35b642c6c8 Improve type hints in calendar trigger tests (#90827) 2023-04-05 14:08:55 +02:00
epenet
5f3868b141 Add missing type hints to tests (#90218)
* Add type hints to tests

* Revert gree as handled in #90222
2023-03-24 19:34:01 -07:00
Allen Porter
9721ba59b6 Rewrite the calendar trigger to fix potential bugs (#89918)
Update the calander event trigger logic to have more exhaustive coverage. The
trigger will now use a timespan to create an explicit window for considering
upcoming events. The start/end of the time span is now more explicit, rather
than getting it from the alarm time.

The trigger is now broken into composable pieces:
- A timespan object for more explicitly managing the time window
- A function to get events during a time span
- A function to process upcoming events and determine the trigger times

The existing listener is now just responsible for scheduling alarms and glue.

This fixes bug with DST handling where the conversion back and forth between
UTC and timezone ends up dropping events during the jump forward. In practice,
an event was returned from the scanning, but it was never fired by the trigger
because (1) it was filtered out of the interval and (2) the event list was
previously cleared every iteration so it would get dropped.

Future improvements can bake more invariant checking into this structure.
2023-03-19 23:42:12 -04:00
epenet
ff8b91aeea Add freezer to known test fixtures in pylint (#89825)
Add freezer to known fixtures in pylint
2023-03-16 22:39:41 -04:00
Allen Porter
4ddcb14053 Add additional CalendarEvent validation (#89533)
Add additional event validation
2023-03-14 20:27:38 -04:00
J. Nick Koston
1c57339ec3 Refactor recorder tests to use recorder history API (#89565) 2023-03-11 21:51:16 -05:00
Allen Porter
e1e0400b16 Fix local calendar issue with events created with fixed UTC offsets (#88650)
Fix issue with events created with UTC offsets
2023-02-23 13:37:15 -05:00
Albin Médoc
f40b712664 Fix 500 error when getting calendar events (#88276)
* Fix 500 error when getting calendar event

* Add test for calendar dates in wrong order

* Update calendar tests to use f strings
2023-02-22 15:33:43 +01:00
Erik Montnemery
9989a4787b Fix recorder platform tests (#88330) 2023-02-17 08:22:15 -06: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
fa7acb4f0d Add type hints to integration tests (part 3) (#87844) 2023-02-10 16:05:01 +01:00
epenet
807c69f621 Add type hints to integration tests (b-c) (#87698) 2023-02-08 18:08:43 +01:00
Allen Porter
7ff1265b10 Add service to create calendar events (#85805) 2023-01-25 12:43:50 +01:00
Allen Porter
624c93bb38 Add Local calendar edit support (#84141)
* Add update support for calendars and implement in local calendar

* Fix supported feature for update calendar

* Increase test coverage for websocket error cases

* Improve test coverage for update failure cases

* Improve test coverage by sharing code between update and create

* Update homeassistant/components/calendar/__init__.py

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 12:36:43 -08:00
Erik Montnemery
a6217ca9b9 Improve error message when an automation fails to validate (#83977) 2022-12-21 23:20:50 +01:00
Allen Porter
69dab4acfe Reduce unnecessary alarm firing to speed up calendar trigger test (#80732) 2022-10-21 10:47:37 -04:00
Allen Porter
d1d218444b Improve calendar trigger test quality (#79451)
Improve calendar test quality
2022-10-21 10:56:17 +02:00
Erik Montnemery
31a787558f Ensure recorder test fixture is setup before hass fixture (#80528)
* Ensure recorder test fixture is setup before hass fixture

* Adjust more tests
2022-10-19 07:58:47 +02:00
Allen Porter
ddf668d1cb Remove CalendarEventDevice which was deprecated in 2022.5 (#77809) 2022-09-04 22:25:43 -07:00
Allen Porter
939c33b1dc Exclude calendar description from recorder (#75375) 2022-07-17 13:31:14 -07:00