Commit Graph

102 Commits

Author SHA1 Message Date
Jan Bouwhuis 3a42bd35e7
Test platform setup errors are notified (#104384)
Test setup errors are notified
2023-11-22 21:16:12 +01:00
Erik Montnemery 4536fb3541
Remove mock_entity_platform test helper (#104073) 2023-11-16 16:55:08 +01:00
Erik Montnemery 97cc05d0b4
Make it possible to restart core in safe mode (#102606) 2023-10-24 14:47:58 +02:00
Erik Montnemery b953f2998c
Rename the safe_mode integration to recovery_mode (#102581)
* Rename safe mode integration to recovery mode

* Update code
2023-10-24 09:11:14 +02:00
Erik Montnemery c481fdb7d0
Rename safe mode to recovery mode (#102580) 2023-10-23 20:33:08 +02:00
Marc Mueller 544d6b05a5
Replace mock_coro with AsyncMock (#99014)
* Replace mock_coro with AsyncMock

* Remove mock_coro test helper function

* Remove redundant AsyncMock
2023-08-25 22:54:55 +02:00
Jan Bouwhuis fc0c8bf113
Improve comment on patching the _import method in test bootstrap dependencies test (#91848) 2023-04-22 13:40:38 +02:00
Jan Bouwhuis 4de124cdd5
Follow up on comments on changes bootstrap tests (#91803)
* Remove commented code

* Add comment to explain mock

* typo
2023-04-21 21:44:14 +03:00
Jan Bouwhuis da26b0a930
Ensure dependencies are awaited correctly when setting up integrations (#91454)
* Do not wait

* Correct tests

* Manage after dependencies stage 1

* test bootstrap dependencies

* Assert log the dependenciy is waited for

* Improve docstrings

* Assert outside callback

* Patch async_get_integrations

* Revert changes made to snips integration

* Undo changes to mqtt_statestream
2023-04-21 08:33:50 +02:00
epenet 9705607db4
Fix lingering timer in cloud (#90822)
* Fix lingering timer in cloud

* Rename variable

* Improve

* Improve again

* Adjust

* Adjust

* Add property to HassJob instead

* Adjust

* Rename

* Adjust

* Adjust

* Make it read-only

* Add specific test
2023-04-07 11:38:17 +02:00
J. Nick Koston f60e9c71a2
Make bootstrap cancelation safe (#90420) 2023-03-28 11:22:41 -10:00
epenet 81c0382e4b
Fix lingering timer in bootstrap tests (#89790)
* Fix lingering timer in bootstrap test

* Adjust comment

* Use a constant
2023-03-16 17:20:27 -04:00
epenet fec6236dd9
Add type hints to root tests (#89785) 2023-03-16 11:08:47 +01:00
epenet a51cc75f03
Add type hints to core tests (part 2) (#88492) 2023-02-21 09:27:13 +01:00
Jan Bouwhuis 4f6a25b470
Allow parameterizing YAML config in tests (#87981)
* Add fixture to parameterize yaml config

* Apply to more tests

* Re-add @fixture label

* Add fixtures to patch yaml content and targets

* Typo

* Improve docstr

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update references to mock_yaml_configuration

* Apply new fixtures

* Apply to check_config tests

* Follow up comments

* Rename fixtures, update docstr

* Split paths

* Patch load_yaml_config_file instead

* sort

* Fix tests

* improve docst

* Rename fixtures

* sorting

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Improve docstr

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Improve docstr

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Improve docstr

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Improve docstr

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Improve docstr

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Improve docstr

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-02-20 16:57:12 +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 b7b82b1e3f
Add more type hints to conftest.py (#87842)
* Add more type hints in conftest.py

* Adjust stop_hass

* Adjust mock_integration_frame

* Adjust pylint plugin
2023-02-11 13:48:53 +01: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
Franck Nijhof bfbf9b9751
Adjusts imports in tests to match our relative import rules (#86788) 2023-01-27 12:51:58 +01:00
epenet 30bf0634fe
Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +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
Charles Garwood 58d531841b
Fix typo SIGNAL_BOOTSTRAP_INTEGRATONS -> SIGNAL_BOOTSTRAP_INTEGRATIONS (#79970) 2022-10-09 17:06:28 -10:00
Erik Montnemery 61ff1b786b
Add a context variable holding a HomeAssistant reference (#76303)
* Add a context variable holding a HomeAssistant reference

* Move variable setup and update test

* Refactor

* Revert "Refactor"

This reverts commit 346d005ee6.

* Set context variable when creating HomeAssistant object

* Update docstring

* Update docstring

Co-authored-by: jbouwh <jan@jbsoft.nl>
2022-08-22 15:58:01 +02:00
Erik Montnemery fd6ffef52f
Support non-live database migration (#72433)
* Support non-live database migration

* Tweak startup order, add test

* Address review comments

* Fix typo

* Clarify comment about promoting dependencies

* Tweak

* Fix merge mistake

* Fix some tests

* Fix additional test

* Fix additional test

* Adjust tests

* Improve test coverage
2022-07-22 15:11:34 +02:00
Joakim Sørensen 3a0111e65d
Use supervisor envs instead of hassio (#72601) 2022-05-30 12:00:13 +02:00
Erik Montnemery cf4033b1bc
Simplify time zone setting in tests (#68330)
* Simplify timezone setting in tests

* Fix typo

* Adjust caldav tests

* Adjust input_datetime tests

* Adjust time_date tests

* Adjust tod tests

* Adjust helper tests

* Adjust recorder tests

* Adjust risco tests

* Adjust aemet tests

* Adjust flux tests

* Adjust forecast_solar tests

* Revert unnecessary change in forecast_solar test

* Adjust climacell tests

* Adjust google tests

* Adjust sensor tests

* Adjust sonarr tests

* Adjust template tests

* Adjust zodiac tests

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-03-20 10:25:15 +01:00
Franck Nijhof 3afadf8adb
Revert "Block peer certs on supervisor" (#67104) 2022-02-23 12:32:07 +01:00
Paulus Schoutsen 938b64081b
Block peer certs on supervisor (#66837)
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
2022-02-22 13:59:40 -08:00
Erik Montnemery 8d6e2ae354
Import persistent notification part 1 (#63898) 2022-01-11 17:24:59 +01:00
J. Nick Koston 5709640453
Report integrations that block startup wrap up (#56003) 2021-09-09 20:39:22 -07:00
Paulus Schoutsen e0f640c0f8
Guard for doRollover failing (#55669) 2021-09-03 09:53:47 -07:00
jan iversen 3a0a8da648
Change logging to do rollover() instead of rotate() (#55177)
* Change to rollover from rotate.

* Remove test log files.
2021-08-25 17:32:48 +02:00
jan iversen 1e3452496a
Make log rollover at startup (#54865)
* Secure log rollover at startup.

* Review comments.

* Please CI.
2021-08-20 17:59:10 +02:00
J. Nick Koston 564e7fa53c
Avoid sending empty integration list multiple times during subscribe_bootstrap_integrations (#49181) 2021-04-15 23:16:17 -07:00
J. Nick Koston 12e3bc8101
Provide api to see which integrations are being loaded (#48274)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-04-04 22:11:44 -10:00
Erik Montnemery ed31cc363b
Wait for registries to load at startup (#46265)
* Wait for registries to load at startup

* Don't decorate new functions with @bind_hass

* Fix typing errors in zwave_js

* Load registries in async_test_home_assistant

* Tweak

* Typo

* Tweak

* Explicitly silence mypy errors

* Fix tests

* Fix more tests

* Fix test

* Improve docstring

* Wait for registries to load
2021-02-11 17:36:19 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Philip Allgaier dde6305549
Cleanup unused loggers (components N-Z + tests) (#41982) 2020-10-16 21:24:08 -05:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
Joakim Plate bcd604eec2
Detect lingering threads after tests (#37270)
* Detect lingering threads after tests

* Make sure cast is setup before checking state

* Make sure we ask executors of old hass to shutdown

We are not waiting here, just hoping for the best

* Make sure all instances of hass and executors is stopped.

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Also apply hass stopping to scripts

* Adjust to changes how we set up executor

* Add new CoreState.stopped

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-07-09 16:15:14 +02:00
Paulus Schoutsen f49ce5d1b4
Protect loop set default executor (#37438)
Co-authored-by: J. Nick Koston <nick@koston.org>
2020-07-06 15:58:53 -07:00
Paulus Schoutsen 5642027ffb
Improve after_dependencies handling (#36898) 2020-06-19 17:24:33 -07:00
Paulus Schoutsen 94132e5572
Add internal/external url to safe mode (#36894) 2020-06-17 17:14:48 -07:00
J. Nick Koston 00387bf870
Make the frontend available sooner (Part 2 of 2) (#36264)
* Part 1 of 2 (no breaking changes in part 1).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

Frontend Changes (home-assistant/frontend#6068)

* Part 1 of 2 (no breaking changes in part 1).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

Frontend Changes (home-assistant/frontend#6068)

* Part 2 of 2 (breaking changes in part 2).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

* bump timeout to 1800s, adjust comment

* bump timeout to 1800s, adjust comment

* bump timeout to 4h

* bump timeout to 4h

* remove timeout failsafe

* remove timeout failsafe

* and the test

* and the test

* find the test that needs mocking

* find the test that needs mocking

* Revert "find the test that needs mocking"

This reverts commit 064e7787a8e9bc65df965530726fa1c41f8bcd36.

* Revert "find the test that needs mocking"

This reverts commit 064e7787a8e9bc65df965530726fa1c41f8bcd36.

* fix the one that was missed due to the conflict
2020-06-02 17:02:09 -05:00
J. Nick Koston 578d4a9b6a
Make the frontend available sooner (Part 1 of 2) (#36263)
* Part 1 of 2 (no breaking changes in part 1).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

Frontend Changes (home-assistant/frontend#6068)

* Address review comments

* bump timeout to 1800s, adjust comment

* bump timeout to 4h

* remove timeout failsafe

* and the test
2020-06-02 13:54:11 -05:00
Pascal Vizeli ed014e3c96
Revert "Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)" (#36251)
This reverts commit fbe7b4ddfa.
2020-05-29 10:18:39 +02:00
J. Nick Koston fbe7b4ddfa
Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-05-28 21:09:07 -07:00
J. Nick Koston 5183c40b23
Periodically log when integrations are taking a while to setup (#36208)
* Periodicly log when intergrations are taking a while to setup

When one or more intergrations are taking a while to setup
it is hard to determine which one is the cause.  We can
help narrow this down for the user with a periodic log
message about which domains are still waiting to be setup
every 30s.

* 30 -> 60 per discussion

* only log when the integration is actually doing setup

* reduce, fix race in test
2020-05-28 18:48:42 -05:00
J. Nick Koston 73616520c0
Use built in queue log handlers to avoid formatting logs in the event loop (#35633)
* Use built in queue log handlers to avoid formatting logs in the event loop

Logging is now formatted and written in another thread to
ensure there is minimal impact on the event loop when
a log message is processed.

This change replaces the existing AsyncHandler log handler
as python 3.7+ now offers an off the shelf solution

* add a simple test

* s/async_migrate_log_handlers_to_queue/async_activate_log_queue_handler/g
2020-05-16 09:29:58 -05:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00