Commit Graph

237 Commits (880b315890da29165fcd146bf29c081c6b399a28)

Author SHA1 Message Date
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
J. Nick Koston 327796a750
Eagerly unload config entries in tests (#111707)
This is a small latancy reduction to reduce test wall clock time
since it runs every test
2024-02-28 14:03:21 -05:00
Franck Nijhof e0a9dcd996
Add label registry (#110821) 2024-02-19 11:59:08 +01:00
Franck Nijhof 4570eed6f6
Add floor registry (#110741)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-02-17 21:21:15 +01:00
Marc Mueller 2ef2172b01
Convert test helpers to get hass instance to contextmanagers (#109990)
* Convert get_test_home_assistant helper to contextmanager

* Convert async_test_home_assistant helper to contextmanager

* Move timezone reset to async_test_home_assistant helper
2024-02-11 21:23:51 +01:00
J. Nick Koston 9c22226fed
Ensure bluetooth auto recovery does not run in tests (#109163)
If time was moved forward too much the scanner would try to auto recover
2024-01-30 23:48:05 -05:00
Marc Mueller 030727b078
Remove deprecated event_loop fixtures in tests (#109048) 2024-01-29 14:24:58 +01:00
J. Nick Koston 4b7a313ece
Use identity checks for CoreState (#107846)
Some of the checks used ==, and some used is. Switch
everything to is as its faster
2024-01-12 10:21:26 +01:00
Ville Skyttä 24b1e01d71
Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
J. Nick Koston 4bdfea5d67
Remove HaAsyncServiceBrowser from zeroconf (#105881) 2023-12-18 14:11:06 +01:00
J. Nick Koston 755dcd8bc6
Ensure bluetooth auto recovery does not run in tests (#105841) 2023-12-16 06:09:03 -10:00
Martin Hjelmare 2631fde0f7
Patch aiohttp server app router freeze in tests (#105555)
* Add test for registering a http view late

* Patch aiohttp server app router freeze

* Correct language
2023-12-12 14:40:38 +01:00
J. Nick Koston cc85e89cf2
Make network fixture scoped to session to speed up tests (#105353) 2023-12-09 10:19:08 +01:00
J. Nick Koston b6245c834d
Move local bluetooth scanner code into habluetooth library (#104970) 2023-12-05 07:19:02 -10:00
Franck Nijhof 7ec2980e52
Change pytest fixture scope from core fixtures (#104831) 2023-12-01 07:14:13 +01:00
J. Nick Koston bf87773d87
Fix zeroconf mocking (#104144) 2023-11-17 16:20:54 -06:00
Marc Mueller 915f5bf84e
Reset the threading.local _hass object every time (#101728)
* Reset the threading.local _hass object every time

* Remove reset from hass fixture
2023-10-10 12:43:12 +02:00
Erik Montnemery 8a83e810b8
Reset the threading.local _hass object in tests (#101700) 2023-10-09 13:41:51 +02:00
Erik Montnemery ab2de18f8f
Refactor frame.get_integration_frame (#101322) 2023-10-03 19:21:27 +02:00
Erik Montnemery 6e6680dc4d
Enable asyncio debug mode in tests (#100197) 2023-09-12 10:12:22 -05:00
J. Nick Koston 1ab2e900f9
Improve lingering timer checks (#99472) 2023-09-02 12:43:27 -05:00
Erik Montnemery defd9e4001
Don't compile missing statistics when running tests (#99446) 2023-09-02 10:09:46 -05:00
Erik Montnemery 91faa53843
Don't allow hass.config.config_dir to be None (#98442) 2023-08-16 13:00:14 +02:00
Erik Montnemery a77009c3ca
Patch dt_util.utcnow earlier (#98050) 2023-08-08 19:16:52 +02:00
Franck Nijhof b286da211a
Add is_admin check to check configuration API (#97788) 2023-08-04 19:25:01 +02:00
Marc Mueller fe0fe19be9
Use datetime.UTC alias [3.11] (#97067) 2023-07-22 17:05:11 -05:00
J. Nick Koston f36930f165
Fix zeroconf tests with cython 3 (#97054) 2023-07-22 12:33:37 -05:00