Commit graph

113 commits

Author SHA1 Message Date
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
Erik Montnemery
704000c049
Add support for breakpoints in scripts (#47632) 2021-03-09 21:23:11 -08:00
Erik Montnemery
8fe51b8ea7
Store automation traces indexed by run_id (#47509)
* Store traces indexed by run_id

* Format

* Add test

* Add test

* Clarify comment
2021-03-08 18:04:41 +01:00
Erik Montnemery
2f9d03d115
Merge action and condition traces (#47373)
* Merge action and condition traces

* Update __init__.py

* Add typing to AutomationTrace

* Make trace_get prepare a new trace by default

* Correct typing of trace_cv

* Fix tests
2021-03-06 12:57:21 +01:00
Erik Montnemery
17401cbc29
Initial automation tracing (#46755)
* Initial prototype of automation tracing

* Small fixes

* Lint

* Move trace helpers to its own file

* Improve trace for state and numeric_state conditions

* Tweaks + apply suggestions from code review

* Index traces by automation_id, trace while script is running

* Refactor condition tracing

* Improve WS API to get traces for single automation

* Add tests

* Fix imports

* Fix imports

* Address review comments

* Cap logging of loops

* Remove unused ContextVar action_config
2021-03-04 14:16:24 +01:00
Erik Montnemery
2d70806035
Add support for "alias" in script steps device, device_condition, and conditions (#46647)
Co-authored-by: Donnie <donniekarnsinsb@hotmail.com>
2021-02-20 19:21:09 -08:00
Erik Montnemery
58b4a91a5b
Test that variables are passed to wait_for_trigger script action (#46221) 2021-02-09 00:34:18 +01:00
Anders Melchiorsen
48002f47f4
Use caplog fixture for log capturing (#46214) 2021-02-08 14:33:57 +01:00
Anders Melchiorsen
b9b1caf4d7
Raise ConditionError for numeric_state errors (#45923) 2021-02-08 10:47:57 +01:00
J. Nick Koston
243014bff1
Fix test_wait_template_with_utcnow (#45356) 2021-01-20 23:56:00 +01:00
J. Nick Koston
a7741be9bb
Wait for all triggers when one fails to attach (#45361) 2021-01-20 22:13:21 +01:00
J. Nick Koston
7c93a11aba
Fix wait_template incorrectly matching falsey values (#44938) 2021-01-08 13:07:50 +01:00
Franck Nijhof
65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00