Commit Graph

184 Commits

Author SHA1 Message Date
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
Erik Montnemery
6490dcf099 Import mqtt and recorder locally in test fixtures (#85067) 2023-01-03 20:18:36 +01:00
Joakim Plate
987e77780a Only run garbage collection per module (#84681)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-01-02 09:31:12 -10:00
Joakim Plate
cb982294bd Avoid logging increase during tests (#84672) 2022-12-28 22:12:25 +01:00
Joakim Plate
94a02e7613 Switch to orjson for tests (#84674) 2022-12-28 03:36:58 +01:00
J. Nick Koston
9008006ac8 Restore remote discovered devices between remote scanner restarts (#83699) 2022-12-11 09:02:55 -10:00
Joakim Plate
c196fefe31 Reduce log level for linger task/timer (#83703)
We don't need to warn that loudly for these issues.
2022-12-10 12:12:56 +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
Erik Montnemery
f869ce9d06 Validate common statistics DB schema errors on start (#79707)
* Validate common statistics db schema errors on start

* Fix test

* Add tests

* Adjust tests

* Disable statistics schema validation in tests

* Update after rebase
2022-11-29 10:16:08 +01:00
J. Nick Koston
d6e287f47a Add manufacturer and model to bluetooth adapter device (#82769)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-11-27 15:44:44 -05:00
J. Nick Koston
47c66dbed4 Offload platform specific bluetooth code to bluetooth-adapters (#82196)
* Offload platform specific bluetooth code to bluetooth-adapters

* adjust

* fix some more patch targets

* more test fixes

* almost there

* may not be setup yet

* more fixes

* fixes

* fix test

* fix merge
2022-11-17 14:34:19 -05:00
Erik Montnemery
f4951a4f31 Add CI job which runs recorder tests on MariaDB (#80586)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-10-19 13:04:28 +02:00
Erik Montnemery
31a787558f Ensure recorder test fixture is setup before hass fixture (#80528)
* Ensure recorder test fixture is setup before hass fixture

* Adjust more tests
2022-10-19 07:58:47 +02:00
Erik Montnemery
416aad32cc Don't mock out migration in recorder tests (#80480) 2022-10-17 22:17:08 +02:00
Erik Montnemery
4fcd0f3e23 Fix recorder fixtures (#79147) 2022-09-27 17:00:06 +02:00
Erik Montnemery
e66f28f3f7 Teach sqlite3 about HAFakeDatetime (#78756) 2022-09-19 23:09:50 +02:00
J. Nick Koston
18eef5da1f Restore history from bluetooth stack at startup (#78612) 2022-09-17 16:58:19 -05:00
Jan Bouwhuis
7fc294d9b1 Set cv hass in hass fixture (#77271)
* Set cv hass in hass fixture

* Move test_hass_cv and update docstring

* Update tests/test_test_fixtures.py

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

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-08-25 12:29:31 +02:00
J. Nick Koston
f6a03625ba Implement websocket message coalescing (#77238)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-08-24 22:50:48 -05:00
J. Nick Koston
cd59d3ab81 Add support for multiple Bluetooth adapters (#76963) 2022-08-18 21:41:07 -04:00
J. Nick Koston
3bcc274dfa Rework bluetooth to support scans from multiple sources (#76900) 2022-08-17 10:51:56 -10:00
J. Nick Koston
6f3cdb6db1 Reorganize bluetooth integration to prepare for remote and multi-adapter support (#76883) 2022-08-16 14:52:53 -10:00
J. Nick Koston
a813cf987b Add bluetooth options flow to pick the adapter (#75701) 2022-07-25 16:52:35 +02:00
J. Nick Koston
38bccadaa6 Add support for setting up and removing bluetooth in the UI (#75600)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-07-22 13:19:53 -05: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
Erik Montnemery
9d0a252ca7 Improve handling of MQTT config entry data (#72691)
* Improve handling of MQTT config entry data

* Add test

* Add warning

* Adjust tests
2022-07-22 13:36:43 +02:00
J. Nick Koston
a3c1926da5 Add mock_bluetooth fixture (#75075) 2022-07-14 07:40:17 -05:00
J. Nick Koston
08ff1b8986 Fix flapping system log test (#75111) 2022-07-14 11:05:52 +02:00
Jan Bouwhuis
52561ce076 Update MQTT tests to use the config entry setup (#72373)
* New testframework and tests for fan platform

* Merge test_common_new to test_common

* Add alarm_control_panel

* Add binary_sensor

* Add button

* Add camera

* Add climate

* Add config_flow

* Add cover

* Add device_tracker_disovery

* Add device_trigger

* Add diagnostics

* Add discovery

* Add humidifier

* Add init

* Add lecacy_vacuum

* Add light_json

* Add light_template

* Add light

* Add lock

* Add number

* Add scene

* Add select

* Add sensor

* Add siren

* Add state_vacuum

* Add subscription

* Add switch

* Add tag

* Add trigger

* Add missed tests

* Add another missed test

* Add device_tracker

* Remove commented out code

* Correct tests according comments

* Improve mqtt_mock_entry and recover tests

* Split fixtures with and without yaml setup

* Update fixtures manual_mqtt

* Update fixtures mqtt_json

* Fix test tasmota

* Update fixture mqtt_room

* Revert fixture changes, improve test

* re-add test
2022-06-02 14:24:46 +02:00
Jan Bouwhuis
ed1c2ea2b8 Move manual configuration of MQTT fan and light to the integration key (#71676)
* Processing yaml config through entry setup

* Setup all platforms

* Update homeassistant/components/mqtt/__init__.py

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

* adjust mock_mqtt - reference config from cache

* Fix test config entry override

* Add tests yaml setup

* additional tests

* Introduce PLATFORM_SCHEMA_MODERN

* recover temporary MQTT_BASE_PLATFORM_SCHEMA

* Allow extra key in light base schema, restore test

* Fix test for exception on platform key

* One deprecation message per platform

* Remove deprecation checks from modern schema

* Update homeassistant/components/mqtt/fan.py

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

* Update homeassistant/components/mqtt/fan.py

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

* Update homeassistant/components/mqtt/light/__init__.py

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

* Update homeassistant/components/mqtt/light/__init__.py

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

* Update homeassistant/components/mqtt/light/schema_json.py

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

* Update homeassistant/components/mqtt/light/schema_template.py

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

* Update homeassistant/components/mqtt/mixins.py

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

* rename validate_modern_schema

* Do not fail platform if a single config is broken

* Update homeassistant/components/mqtt/__init__.py

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

* Fix tests on asserting log

* Update log. Make helper transparant, remove patch

* Perform parallel processing

* Update tests/components/mqtt/test_init.py

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

* Apply suggestions from code review

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

* Update homeassistant/components/mqtt/mixins.py

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

* black

* Fix tests and add #new_format anchor

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2022-05-19 15:04:53 +02:00
J. Nick Koston
222baa53dd Make database access in the eventloop raise an exception (#71547) 2022-05-09 15:22:08 -05:00
Erik Montnemery
f96c1136b0 Bump pytest-socket to 0.5.1 (#69624)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-04-26 10:42:37 -10:00
Erik Montnemery
3016b5fbfc Use recorder fixtures and helpers in tests (#70773) 2022-04-26 06:08:00 -10:00
Erik Montnemery
28ebab9c5a Simplify waiting for recorder in tests (#70647) 2022-04-25 12:04:47 +02:00
Erik Montnemery
982e314de6 Use recorder_mock in tests (#70363)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-04-22 19:29:44 -10:00
J. Nick Koston
23de8d4156 Revert changes to test/conftest.py from #70300 (#70385) 2022-04-21 10:49:47 -10:00
J. Nick Koston
309424d3b9 Prevent tests changing units from affecting other tests (#70300)
* Prevent tests changing temperature_unit from affecting other tests

* tweak
2022-04-19 11:38:52 -10:00
J. Nick Koston
fe6a4bfb1d Remove EVENT_TIME_CHANGED and EVENT_TIMER_OUT_OF_SYNC (#69643)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-04-09 09:05:54 -10:00
Erik Montnemery
7e8d52e5a3 Fix race when handling rapid succession of MQTT discovery messages (#68785)
Co-authored-by: jbouwh <jan@jbsoft.nl>
2022-03-29 20:26:11 -07:00
Marc Mueller
c9cc2eb7c8 Fix flaky datetime test (#68524) 2022-03-23 09:30:01 +01:00
Erik Montnemery
247af2e74f Improve recorder setup in tests (#68333)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-03-21 15:49:18 -07: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
Erik Montnemery
d360ac91ca Disable recorder nightly jobs in tests (#68188) 2022-03-15 09:23:52 -07:00