1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-17 14:01:34 +01:00
Commit Graph

125 Commits

Author SHA1 Message Date
epenet 913156b0e0 Avoid lingering timer on script shutdown (#89753) 2023-03-16 08:00:21 +01:00
Erik Montnemery d90ee85118 Allow conditions to be implemented in platforms (#88509)
* Allow conditions to be implemented in platforms

* Update tests

* Tweak typing

* Rebase fixes
2023-02-23 22:30:51 -05:00
epenet 5f25b71df7 Add type hints to core tests (#88478) 2023-02-20 11:42:56 +01:00
Franck Nijhof d3ed8de232 Update Ruff to v0.0.247 (#88210)
* Update Ruff to v0.0.247

* Fix new found violations
2023-02-15 16:46:03 -05: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
Paulus Schoutsen d54f59478f Keep task references while running (#87970)
* Keep task references while running

* Update pilight tests pointing at correct logger call

* Fix graphite tests

* Fix profiler tests

* More graphite test fixes

* Remove extra sleep

* Fix tests

* Shutdown background tasks as part of stage 1

* Remove unnecessary sleep in test

* Remove unused method on mock hass

* Skip on cancelled too

* Remove background tasks

* Test trigger variables without actually sleeping

* Fix graphite

* One more graphite grrrrrrr
2023-02-13 23:16:59 -05:00
epenet c98b4e3204 Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
Karlie Meads e40a9822f5 Fix disabled condition within an automation action (#87213)
fixes undefined
2023-02-02 22:35:02 +01:00
Franck Nijhof 57cf11f067 Enable Ruff PT015 (#86775) 2023-01-27 11:10:29 +01:00
Franck Nijhof e50a531cd9 Code styling tweaks to the tests - Part 2 (#86662)
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
epenet 30bf0634fe Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Erik Montnemery 1e2f00e186 Improve device automation validation (#86143) 2023-01-21 00:44:17 +01:00
Joakim Plate c576a68d33 Upgrade pytest-aiohttp (#82475)
* Upgrade pytest-aiohttp

* Make sure executors, tasks and timers are closed

Some test will trigger warnings on garbage collect, these warnings
spills over into next test.

Some test trigger tasks that raise errors on shutdown, these spill
over into next test.

This is to mimic older pytest-aiohttp and it's behaviour on test
cleanup.

Discussions on similar changes for pytest-aiohttp are here:
https://github.com/pytest-dev/pytest-asyncio/pull/309

* Replace loop with event_loop

* Make sure time is frozen for tests

* Make sure the ConditionType is not async

  /home-assistant/homeassistant/helpers/template.py:2082: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    def wrapper(*args, **kwargs):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

* Increase litejet press tests with a factor 10

The times are simulated anyway, and we can't stop the normal
event from occuring.

* Use async handlers for aiohttp

tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
  /Users/joakim/src/hass/home-assistant/venv/lib/python3.9/site-packages/aiohttp/web_urldispatcher.py:189: DeprecationWarning: Bare functions are deprecated, use async ones
    warnings.warn(

* Switch to freezegun in modbus tests

The tests allowed clock to tick in between steps

* Make sure skybell object are fully mocked

Old tests would trigger attempts to post to could services:

```
DEBUG:aioskybell:HTTP post https://cloud.myskybell.com/api/v3/login/ Request with headers: {'content-type': 'application/json', 'accept': '*/*', 'x-skybell-app-id': 'd2b542c7-a7e4-4e1e-b77d-2b76911c7c46', 'x-skybell-client-id': '1f36a3c0-6dee-4997-a6db-4e1c67338e57'}
```

* Fix sorting that broke after rebase
2022-11-29 22:36:36 +01:00
Erik Montnemery eb10654e01 Add test for failing conditions in sub scripts (#71238) 2022-05-03 13:06:13 +02:00
Franck Nijhof 99360ad7f4 Indicate disabled steps in script trace (#71237) 2022-05-03 13:04:59 +02:00
Erik Montnemery 92f1855bcf Fix script conditions (#71235) 2022-05-03 11:28:08 +02:00
Erik Montnemery 1931600eac Isolate parallel subscripts (#71233) 2022-05-03 10:36:58 +02:00
Erik Montnemery f6c2fb088c Stop script if sub-script stops or aborts (#71195) 2022-05-02 14:59:58 +02:00
Franck Nijhof 682ac52a20 Support shorthand logical operators in script sequences (#71022) 2022-04-29 18:06:21 +02:00
Franck Nijhof 35687def02 Merge stop & error script actions (#70109) 2022-04-20 14:22:37 -07:00
Thomas Lovén b50f369fe4 Add shorthand notation for boolean conditions (#70120) 2022-04-18 22:09:09 +02:00
Franck Nijhof 1b48d7eda1 Add for each item support to repeat action (#70093) 2022-04-15 19:10:25 +02:00
Franck Nijhof e04fef3c2d Allow disabling specific triggers/actions/conditions (#70082) 2022-04-15 09:33:09 -07:00
Franck Nijhof cdabcce83a Add ability to continue scripts/automations on error (#70004) 2022-04-14 13:43:14 -07:00
Franck Nijhof d704d4f853 Add parallel automation/script actions (#69903) 2022-04-13 13:07:44 -07:00
Franck Nijhof 67b200a532 Add if/else automation/script action (#69811)
Co-authored-by: Erik <erik@montnemery.com>
2022-04-12 15:02:17 +02:00
Franck Nijhof 81d90b1bc7 Add stop/error script/automation action (#67340) 2022-04-11 14:22:22 -07:00
Erik Montnemery 8ea31cea3a Fix deadlock when stopping queued script (#68175) 2022-03-15 08:29:04 -07:00
Erik Montnemery 1a27025793 Prevent spawning script runs when shutting down (#68170) 2022-03-15 12:46:58 +01:00
Paulus Schoutsen c2e62e4d9f Re-org device automations (#67064)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-02-22 13:15:16 -08:00
mk-maddin efb6fd1569 Fix script / automation repeat with count 0 fails (#65448)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-02-03 08:18:58 -08:00
Erik Montnemery e2fca2e305 Support shorthand templates in condition actions (#61177)
* Support shorthand templates in condition actions

* Fix validation message

* Fix tests
2021-12-21 12:19:31 +01:00
Erik Montnemery 17dc609363 Correct validation of conditions in scripts and automations (#60890)
* Correct validation of conditions in scripts and automations

* Fix test
2021-12-03 09:08:28 -08:00
Erik Montnemery 0e3bc21d54 Teach state and numeric_state conditions about entity registry ids (#60841) 2021-12-02 14:55:12 -08:00
Erik Montnemery c85bb27d0d Teach state trigger about entity registry ids (#60271)
* Teach state trigger about entity registry ids

* Tweak

* Add tests

* Tweak tests

* Fix tests

* Resolve entity ids during config validation

* Update device_triggers

* Fix mistake

* Tweak trigger validator to ensure we don't modify the original config

* Add index from entry id to entry

* Update scaffold

* Pre-compile UUID regex

* Address review comment

* Tweak mock_registry

* Tweak

* Apply suggestion from code review
2021-12-02 14:26:45 +01:00
Erik Montnemery ea102f71a6 Correct validation of repeats in scripts and automations (#60318)
* Correct validation of repeats in scripts and automations

* Improve validation test
2021-11-26 14:12:59 +01:00
J. Nick Koston 10d6247fee Bump to aiohttp 3.8.0 (#58974) 2021-11-04 10:07:50 -05:00
Erik Montnemery 838f79be3d Update tests searching for areas referenced in automations (#57558) 2021-10-13 13:27:56 -07:00
Erik Montnemery 007af4a7aa Search for areas, devices and entities in script choose actions (#57554) 2021-10-12 08:49:07 -07:00
Raman Gupta bef8be9256 Support dynamic schema validation in device conditions and actions (#52007)
* Allow integrations to provide dynamic schema validation in device conditions and actions

* Add tests

* re-add type

* mypy
2021-06-28 09:23:46 +02:00
Ville Skyttä 7d03b02192 Spelling fixes (#51642) 2021-06-11 13:35:03 +02:00
Erik Montnemery 1ea0d8ae02 Correct trace of condition actions (#50800) 2021-05-17 16:54:17 -07:00
Erik Montnemery b35f229674 Include _StopScript.__cause__ in trace (#50441)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-05-11 22:27:11 -07:00
Erik Montnemery ff5fbea1fb Improve trace of template conditions (#49101)
* Improve trace of template conditions

* Refactor

* Fix wait_template trace

* Update tests
2021-04-12 20:22:28 +02:00
Erik Montnemery 9f481e1642 Include script script_execution in script and automation traces (#48576) 2021-04-01 09:42:23 -07:00
Paulus Schoutsen 63e3012380 Fix script default trace (#48390) 2021-03-26 23:56:40 -07:00
Erik Montnemery 272dffc384 Improve script tracing (#48100)
* Improve script tracing

* Fix test
2021-03-22 13:15:45 +01:00
Erik Montnemery f8755a52c2 Warn on undefined variables in templates (#48140)
* Warn on undefined variables in templates

* Add test

* fix tests

* fix tests
2021-03-20 15:16:04 +01:00
Erik Montnemery 7b717bc437 Correct trace for repeat script actions (#48031) 2021-03-18 13:14:06 -07:00
Erik Montnemery 1cde1074c9 Correct trace for choose and repeat script actions (#47973)
* Correct trace for choose and repeat script actions

* only choose-wrap the choices

* Update tests

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2021-03-16 08:49:16 +01:00