263 Commits

Author SHA1 Message Date
Erik Montnemery
6921e053e4
Move recorder data migration implementation to migrators (#122045) 2024-07-17 10:59:58 +02:00
Erik Montnemery
9970b7eece
Refactor recorder data migration (#121009)
* Refactor recorder data migration

* Fix stale docstrings

* Don't store a session object in BaseRunTimeMigration instances

* Simplify logic in EntityIDMigration.migration_done

* Fix tests
2024-07-16 21:50:19 +02:00
J. Nick Koston
19d2d023ab
Ensure states table rebuild still happens if the event_id index was removed (#121938)
* Ensure states table rebuild still happens if the event_id index was removed

If ix_states_event_id was removed by the foreign key still
exists, the states table would not get rebuilt. This should
not happen under normal circumstances and seems to only be
possible if the index was removed manually or Home
Assistant was restarted forcefully in the middle
of a previous migration from years ago.

* cover

* fix tests

* mysql wont allow at that point but thats ok as long as its gone at the end
2024-07-14 23:20:52 +02:00
Erik Montnemery
d55d02623a
Add recorder test fixture to enable persistent SQLite database (#121137)
* Add recorder test fixture to enable persistent SQLite database

* Fix tests directly using async_test_home_assistant context manager
2024-07-04 09:59:37 +02:00
Erik Montnemery
5029da6919
Make the async_setup_recorder_instance fixture a context manager (#121086) 2024-07-03 14:05:34 -05:00
Erik Montnemery
87f7703f3c
Use async_setup_recorder_instance fixture in recorder migration tests (#121050) 2024-07-03 08:56:05 -05:00
epenet
61b2e4ca32
Add Context to service_calls fixture (#120923) 2024-07-01 14:05:30 +02:00
Marc Mueller
ca55986057
Import Generator from collections.abc (1) (#120914) 2024-07-01 11:51:51 +02:00
Joost Lekkerkerker
b56c4a757c
Bump ruff to 0.5.0 (#120749) 2024-06-28 15:23:21 +02:00
Erik Montnemery
4a86693254
Verify default timezone is restored when test ends (#116216) 2024-06-26 09:41:16 +02:00
Erik Montnemery
e32a27a8ff
Remove hass_recorder test fixture (#120295) 2024-06-24 11:14:08 +02:00
Jan Bouwhuis
f1fd52bc30
Fix issue in mqtt fixture calling disconnect handler (#120246) 2024-06-23 10:37:08 -05:00
Robert Resch
bae008b0e2
Remove legacy_api_password auth provider (#119976) 2024-06-19 22:46:30 +02:00
epenet
9f41133bbc
Add missing argument type to core tests (#119667) 2024-06-14 08:42:01 +02:00
J. Nick Koston
d52ce03aa4
Ensure asyncio blocking checks are undone after tests run (#119542)
* Ensure asyncio blocking checks are undone after tests run

* no reason to ever enable twice

* we are patching objects, make it more generic

* make sure bootstrap unblocks as well

* move disable to tests only

* re-protect

* Update tests/test_block_async_io.py

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

* Revert "Update tests/test_block_async_io.py"

This reverts commit 2d46028e21b4095479302629a201c3cfc811b2c2.

* tweak name

* fixture only

* Update tests/conftest.py

* Update tests/conftest.py

* Apply suggestions from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-06-13 08:52:01 +02:00
epenet
9e8f9abbf7
Ignore misplaced-bare-raise warnings in tests (#119403) 2024-06-11 17:59:54 +02:00
epenet
fce4fc663e
Fix import-outside-toplevel pylint warnings in core tests (#119394) 2024-06-11 16:10:34 +02:00
epenet
572700a326
Ignore c-extension-no-member pylint warnings in tests (#119378) 2024-06-11 12:57:43 +02:00
epenet
8cbfc5a58b
Use service_calls fixture in arcam_fmj tests (#119274) 2024-06-10 13:09:51 +02:00
epenet
5166426d0a
Add type hints for service_calls fixture in pylint plugin (#118356) 2024-06-08 16:32:27 +02:00
Marc Mueller
279483ddb0
Import Generator from typing_extensions (2) (#118989) 2024-06-06 17:24:22 +02:00
J. Nick Koston
67b3be8432
Remove useless threading locks in mqtt (#118737) 2024-06-04 14:21:03 -05:00
epenet
37fc16d7b6
Fix incorrect patch type hint in main conftest (#118461) 2024-06-02 15:34:30 +02:00
epenet
a5dc4cb1c7
Fix incorrect zeroconf type hint in tests (#118465)
* Fix incorrect `mock_async_zeroconf` type hint

* Adjust thread

* One more

* Fix mock_zeroconf also

* Adjust

* Adjust
2024-05-30 21:57:09 +02:00
Jan Bouwhuis
bfc3194661
Fix mqtt not publishing null payload payload to remove discovery (#118261) 2024-05-27 12:53:22 -10:00
J. Nick Koston
226d010ab2
Simplify mqtt connection state dispatcher (#118184) 2024-05-26 10:21:21 -10:00
Marc Mueller
1ad8151bd1
Use PEP 695 type alias in tests (#117797) 2024-05-20 19:03:04 +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
Marc Mueller
25d1ca747b
Use PEP 695 for decorator typing (3) (#117640) 2024-05-17 16:27:32 +02:00
J. Nick Koston
b061e7d1aa
Small speed up to setting up integrations and config entries (#117278)
* Small speed up to setting up integration and config entries

When profiling tests, I noticed many calls to get_running_loop. In the places
where we are already in a coro, pass the existing loop so it does not have to
be looked up. I did not do this for places were we are not in a coro since there
is risk that an integration could be doing a non-thread-safe call and its better
that the code raises when trying to fetch the running loop vs the performance
improvement for these cases.

* fix merge

* missed some
2024-05-11 22:39:20 -04:00
J. Nick Koston
481de8cdc9
Ensure config entry operations are always holding the lock (#117214)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-05-12 08:20:08 +09:00
J. Nick Koston
d7aa24fa50
Only load translations for an integration once per test session (#117118) 2024-05-11 12:00:02 +09:00
J. Nick Koston
333d5a9251
Speed up test teardown when no config entries are loaded (#117095)
Avoid the gather call when there are no loaded config entries
2024-05-09 10:14:07 -04:00
Sid
ac54cdcdb4
Enable Ruff RUF010 (#115371)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-08 23:54:49 +02:00
J. Nick Koston
6eeeafa8b8
Speed up tests by making mock_get_source_ip session scoped (#117096) 2024-05-08 23:42:35 +02:00
Erik Montnemery
27fcf72275
Convert history tests to use async API (#116447)
* Convert history tests to use async API

* Add new fixture to help patch recorder

* Modify

* Modify

* Update tests/conftest.py

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

* Rename fixture

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-05-03 08:14:46 +02:00
epenet
48b1678075
Add test helper to remove device (#116234)
* Add test helper to remove device

* Rename

* Fix signature
2024-04-28 18:50:15 +02:00
Erik Montnemery
10be8f9683
Simplify timezone setting in recorder test (#116220) 2024-04-26 15:14:23 +02:00
Sid
e662e3b65c
Bump ruff to 0.4.2 (#116201)
* Bump ruff to 0.4.2

* review comments
2024-04-26 08:48:32 +02:00
J. Nick Koston
423544401e
Convert MQTT to use asyncio (#115910) 2024-04-21 22:33:58 +02:00
Jan-Philipp Benecke
f08af5dc6d
Avoid use of hass.helpers in _mqtt_mock_entry fixture (#114536) 2024-03-31 11:33:59 -10:00
Joost Lekkerkerker
6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Jan-Philipp Benecke
ff6812a798
Split light fixture from implementation to only import when fixture is actually used (#113892)
* Split light fixture from implementation to only import when fixture is actually used

* Non-local import
2024-03-21 10:49:32 +01:00
Jan-Philipp Benecke
685468d845
Use mock_platform for light entity component tests instead of hass.components (#113845)
* Use `mock_platform` for light entity component tests instead of `hass.components`

* Move pytest_plugins to top

* Fix comment
2024-03-20 01:09:48 +01:00
Sid
ccd2e989c3
Enable ruff RUF005 and fix occurrences (#113589) 2024-03-16 07:37:20 -10:00
Franck Nijhof
0e2775667d
Add category registry (#110897)
* Add category registry

* Add entity registry support

* Update homeassistant/components/config/entity_registry.py

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

* Use ulid instead

* Add tests for adding same name in different scopes

* Handle keyerror on update

* Lookup tweak

* Omit categories from entity registry snapshots

* Use base registry

* Update snapshots

* Update snapshots

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-15 13:25:16 +01:00
Jan Bouwhuis
caaa03536b
Cleanup mqtt PLATFORMS constant and CI-test platform filters (#112847) 2024-03-09 23:48:54 +01:00
Marc Mueller
19ab3d6daf
Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
J. Nick Koston
1fb9cfe37e
Speed up the frame helper (#112562) 2024-03-06 20:54:09 -10:00
Jan-Philipp Benecke
bc6b4d01c8
Deprecate hass.components and log warning if used inside custom component (#111508)
* Deprecate @bind_hass and log error if used inside custom component

* Log also when accessing `hass.components`

* Log warning only when `hass.components` is used

* Change version

* Process code review
2024-02-29 12:25:46 +01:00