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
J. Nick Koston
e9620c62b8
Fix assertions in zeroconf tests ( #96957 )
2023-07-20 20:36:46 +02:00
Jan Bouwhuis
18ee9f4725
Refactor async_get_hass to rely on threading.local instead of a ContextVar ( #96005 )
...
* Test for async_get_hass
* Add Fix
2023-07-07 14:52:38 -04:00
Joakim Plate
067fc079a3
Don't mock non async with AsyncMock ( #93749 )
2023-05-29 20:20:27 +02:00
epenet
98b1005b63
Ensure config entries are unloaded in tests ( #90850 )
2023-04-22 21:26:07 +02:00
epenet
9e1a670e6e
Fail CI on lingering timers (part 2) ( #89976 )
...
* Fail CI on lingering timers (part 2)
* Improve error message
* Adjust tts
2023-04-13 17:03:52 +02:00
epenet
687c035bb2
Make auth test fixtures async ( #91263 )
...
Make auth fixtures async in tests
2023-04-12 20:43:50 -04:00
epenet
d483ad820c
Make hass test fixture async ( #91264 )
2023-04-12 23:55:40 +02:00
Jan Bouwhuis
bb15923968
Rename MQTT entry mock and cleanup ( #91223 )
...
Rename to mqtt_mock_entry and cleanup
2023-04-12 09:43:03 +02:00
Jan Bouwhuis
4a0d3e881a
Rework MQTT config merging and adding defaults ( #90529 )
...
* Cleanup config merging and adding defaults
* Optimize and update tests
* Do not mix entry and yaml config
* Make sure hass.data is initilized
* remove check on get_mqtt_data
* Tweaks to MQTT client
* Remove None assigment mqtt client and fix mock
2023-04-04 18:12:18 +02:00
J. Nick Koston
4ebce9746d
Add schema auto repairs for states tables ( #90083 )
2023-03-22 10:05:23 -10:00
J. Nick Koston
ddcaa9d372
Break out statistics repairs into a `auto_repairs` modules ( #90068 )
...
* Break out statistics schema repairs into a repairs module
A future PR will add repairs for events, states, etc
* reorg
* reorg
* reorg
* reorg
* fixes
* fix patch targets
* name space rename
2023-03-21 21:08:06 -04:00
epenet
9a784fddef
Fail CI on lingering timers ( #89292 )
2023-03-20 10:20:19 +01:00
epenet
9893b1cf4a
Cleanup get_local_ip in global conftest ( #89826 )
2023-03-16 22:03:06 +01:00
epenet
913156b0e0
Avoid lingering timer on script shutdown ( #89753 )
2023-03-16 08:00:21 +01:00
J. Nick Koston
ccab45520b
Remove asyncio.coroutine workarounds ( #88560 )
2023-03-15 20:04:31 -04:00
J. Nick Koston
b9ac6b4a7c
Improve reliability of context id migration ( #89609 )
...
* Split context id migration into states and events tasks
Since events can finish much earlier than states we
would keep looking at the table because states as not
done. Make them seperate tasks
* add retry dec
* fix migration happening twice
* another case
2023-03-12 21:41:48 -04:00
J. Nick Koston
c41f91be89
Deduplicate entity_id in the states table ( #89557 )
2023-03-12 10:01:58 -10:00
J. Nick Koston
8bd43760b6
Deduplicate event_types in the events table ( #89465 )
...
* Deduplicate event_types in the events table
* Deduplicate event_types in the events table
* more fixes
* adjust
* adjust
* fix product
* fix tests
* adjust
* migrate
* migrate
* migrate
* more test fixes
* more test fixes
* fix
* migration test
* adjust
* speed up
* fix index
* fix more tests
* handle db failure
* preload
* tweak
* adjust
* fix stale docs strings, remove dead code
* refactor
* fix slow tests
* coverage
* self join to resolve query performance
* fix typo
* no need for quiet
* no need to drop index already dropped
* remove index that will never be used
* drop index sooner as we no longer use it
* Revert "remove index that will never be used"
This reverts commit 461aad2c52
.
* typo
2023-03-11 14:54:55 -05:00
J. Nick Koston
170a13302c
Reduce overhead to store context ids in the database ( #88942 )
2023-03-08 14:51:45 -10:00
epenet
c51bde9a26
Fail CI on lingering tasks ( #88905 )
2023-03-07 11:35:48 +01:00
Jan Bouwhuis
4e66554298
Also set `hass.config_entries` when `mock_hass_config` fixture is used ( #88669 )
...
* Set `hass.config_entries` with `mock_hass_config`
* Update tests/conftest.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
---------
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-28 11:14:04 +01:00
Jan Bouwhuis
b25f6e3ffc
Prepare for refactoring of MQTT related tests ( #88557 )
...
* Update mqtt_mock
* Tests manual_mqtt
* Tests mqtt_json
* Tests mqtt_room
2023-02-27 13:54:56 +01:00
Jan Bouwhuis
3afc39dbbf
Set default for `hass_config_yaml` fixture to "" ( #88608 )
...
Set default for hass_config_yaml fixture to ""
2023-02-22 17:18:11 +01:00
Erik Montnemery
356c316b39
Fix stray prints seen inbetween tests ( #88570 )
2023-02-21 17:19:38 -06:00
Jan Bouwhuis
ebb450c946
Default `hass_config` to contain an empty config ( #88515 )
...
* Default hass_config to {}
* Correct type hint
2023-02-21 08:48:44 +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
Erik Montnemery
06213ee595
Drop sqlachemy_utils workaround ( #88393 )
2023-02-18 09:18:23 -06:00
Franck Nijhof
6891eb7ed1
Add support for snapshot testing ( #88323 )
...
* Add support for snapshot testing
* Use snapshots in Elgato diagnostics test
* Use snapshots in Elgato sensor test
* Fix flake8 warning
* Slightly improve serialized output
* Remove snapshot naming in elgato sensor tests
* Improve snapshoting of via_device_id in device registry item
* Update pylint typehints plugin for snapshot fixture typing
* Use snapshots in Elgato configflow test
* Use snapshots in Bluetooth repair issue tests
2023-02-17 16:35:55 -05:00
epenet
a16e298599
Adjust json imports in tests ( #88248 )
2023-02-17 19:13:48 +01:00
J. Nick Koston
c79157208b
Add python 3.11 to the CI ( #88038 )
...
* Remove profiler.memory service
guppy3 is not python3.11 compat
https://github.com/zhuyifei1999/guppy3/issues/41
This service will return if and when guppy3 becomes
python3.11 compat
* squash
* temp remove
* temp dump tests
* temp dump tests
* drop a few more to get a run
* drop a few more to get a run
* Account for changed python3.11 enum.IntFlag behavior in zha
There may be additional changes needed, but I could only
see what needed to be updated based on the tests
* merge
* restore
* restore
* legacy value
* tweak a bit for the python 3.11 timings
* block cchardet
* conditional
* adjust est
* test
* not yet
* tweak
* give a little leeway for timing
* Fix otbr tests
* Increase database test timeout
It looks like we need a little more time to run
with the addiitonal tests in #87019
* Increase database test timeout
It looks like we need a little more time to run
with the addiitonal tests in #87019
* Fix aprs tests with python 3.11
* merge fix
* hints
* Update homeassistant/package_constraints.txt
* Update script/gen_requirements_all.py
* Constrain uamqp for Python 3.10 only
* Bump vulcan-api to 2.3.0
see https://github.com/kapi2289/vulcan-api/pull/126
see https://github.com/home-assistant/core/pull/88038
see https://github.com/home-assistant/docker/pull/260
* add ban
* Bump python-matter-server to 2.1.1
* revert
* Update tests/asyncio_legacy.py
---------
Co-authored-by: Erik <erik@montnemery.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Marcel van der Veldt <m.vanderveldt@outlook.com>
2023-02-16 12:38:32 -05:00
Jan Bouwhuis
950ee34514
Correct typing on hass_storage fixure ( #87986 )
...
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-13 12:12:34 +01: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
6a1cd75a67
Add MockHAClientWebSocket test helper ( #87832 )
...
* Add MockHAClientWebSocket test helper
* Add sample use
* Add missing type hint
2023-02-10 10:23:26 -05:00
epenet
22bfb99db4
Add type hints to requests_mock ( #87757 )
2023-02-10 11:44:09 +01:00
epenet
fac746c974
Improve recorder type hints in tests ( #87826 )
...
* Improve recorder type hints in tests
* Add comment
* Adjust comment
2023-02-10 11:11:39 +01:00
J. Nick Koston
cbaf4764e7
Ensure MySQL tests cleanup connections and raise an exception if they do not ( #87767 )
...
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Erik <erik@montnemery.com>
2023-02-09 16:27:53 -06:00
Erik Montnemery
2fae82a9ef
Really ensure recorder test fixture is setup before hass fixture ( #87796 )
2023-02-09 11:43:14 -06:00
J. Nick Koston
c05a7b29e6
Terminate stale MySQL connections at the end of test runs ( #87794 )
2023-02-09 11:13:13 -06:00
epenet
c946f684bc
Add more type hints to conftest ( #87755 )
...
* Add pytest type hints to conftest
* Add bluetooth and integration frame
2023-02-09 09:20:05 +01:00
epenet
aff0174afa
Add more type hints to conftest ( #87737 )
2023-02-08 22:58:00 +01:00
Franck Nijhof
6551eb168d
Add common area, device, entity and issue registry test fixtures ( #87694 )
2023-02-08 16:28:44 +01:00
Erik Montnemery
94519de8dd
Upgrade SQLAlchemy to 2.0.2 ( #86436 )
...
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-08 08:17:32 -06:00
epenet
a4c4f77f73
Add more fixtures to pylint plugin ( #87685 )
2023-02-08 10:51:09 +01:00
Erik Montnemery
720f51657d
Add CI job which runs recorder tests on PostgreSQL ( #80614 )
...
Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-02-07 09:46:14 -06:00
Jan Bouwhuis
4ad386d794
Correct type hints mqtt_client_mock and move new generator type ( #87527 )
...
* Correct mqtt_client_mock and move MqttMockType
* Rename MqttMockType to MqttMockGenerator
* Make types more specific
* adjust returntype _setup_mqtt_entry
* Correct return type _setup_mqtt_entry
* Update tests/conftest.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
* Update tests/conftest.py
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
---------
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2023-02-06 15:05:06 +01:00
Jan Bouwhuis
97de0c6d9a
Late review on added type hint MQTT fixture ( #87342 )
2023-02-03 22:22:52 +01:00
Jan Bouwhuis
3edfd10f2d
Add type hints for MQTT common helper and fixtures ( #87065 )
2023-02-03 19:27:46 +01:00
Franck Nijhof
5e81d28116
Update black to 23.1.0 ( #87188 )
2023-02-02 18:35:24 +01:00
epenet
7db166b515
Fix tests typing helper ( #86956 )
2023-01-31 08:48:35 +01:00
Franck Nijhof
3b5fd4bd06
Enable Ruff TRY004 ( #86811 )
2023-01-30 14:06:52 +01:00
epenet
7e7a27f8b9
Add type hints to http client fixtures ( #86795 )
2023-01-30 13:40:07 +01:00
Franck Nijhof
8f74bff354
Enable Ruff PLC0414 ( #86799 )
2023-01-27 16:32:04 +01:00
Franck Nijhof
ef800335fb
Enable Ruff PT022 ( #86792 )
...
* Enable Ruff PT022
* Adjust found cases
2023-01-27 13:57:06 +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
53b931e21a
Don't interpret negative verbosity as debug ( #86318 )
...
* Don't interpret negative verbosity as debug
CI run with -qq which is a negative verbosity
* Make sure all caplog tests get debug level
* Update tests/conftest.py
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-01-22 00:03:57 +02:00
Erik Montnemery
d94f007dbf
Import recorder locally in test fixtures ( #86286 )
2023-01-20 14:22:48 +01:00
Franck Nijhof
24fdd588fd
Code styling tweaks to the tests - Part 1 ( #86192 )
2023-01-20 13:52:46 +01:00
J. Nick Koston
551e098177
Make event.time_tracker_utcnow patchable with freezegun ( #86051 )
2023-01-17 09:47:31 +01:00
Ville Skyttä
7eb1b8c2fe
Address a few deprecation warnings in tests ( #85472 )
2023-01-09 00:52:05 +02:00
J. Nick Koston
d81febd3f4
Small speed up to frequently called datetime functions ( #85399 )
2023-01-08 09:42:29 -10:00