45 Commits
Author SHA1 Message Date
3fee05db71 Add entity_platform helper function to create issues when platform setup is not supported by integration (#171105)
Co-authored-by: Erik Montnemery <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
2026-05-19 21:08:03 +02:00
5b2816e56c Fix line length violations in tests/components s (#170990)
Co-authored-by: Simone Chemelli <[email protected]>
2026-05-17 17:14:26 -04:00
epenetandGitHub 88525955ce Remove import annotations from tests (#169527) 2026-04-30 09:30:46 +02:00
G JohanssonandGitHub 67ccdd36fb Allow template in query in sql (#150287) 2025-11-06 17:11:46 +01:00
G JohanssonandGitHub b01f5dd24b Raise repairs on platform setup for sql (#153581) 2025-10-04 07:02:36 +02:00
tronikosandGitHub d6543480ac Refactor SQL integration (#153135) 2025-09-28 19:03:13 +02:00
1428b41a25 Improve sql config flow (#150757)
Co-authored-by: Joost Lekkerkerker <[email protected]>
2025-09-11 12:27:48 +02:00
ff2c901930 Update trigger based template entity resolution order (#140660)
* Update trigger based template entity resolution order

* add test

* fix most comments

* Move resolution to base class

* add comment

* remove uncessary if statement

* add more tests

* update availability tests

* update logic stage 1

* phase 2 changes

* fix trigger template entity tests

* fix trigger template entities

* command line tests

* sql tests

* scrape test

* update doc string

* add rest tests

* update sql sensor _update signature

* fix scrape test constructor

* move state check to trigger_entity

* fix comments

* Update homeassistant/components/template/trigger_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* Update homeassistant/helpers/trigger_template_entity.py

Co-authored-by: Erik Montnemery <[email protected]>

* update command_line and rest

* update scrape

* update sql

* add case to command_line sensor

---------

Co-authored-by: Erik Montnemery <[email protected]>
2025-04-25 13:17:25 +02:00
J. Nick KostonandGitHub ffeefd4856 Bump SQLAlchemy to 2.0.36 (#126683)
* Bump SQLAlchemy to 2.0.35

changelog: https://docs.sqlalchemy.org/en/20/changelog/changelog_20.html#change-2.0.35

* fix mocking

* adjust to .36

* remove ignored as these are now typed

* fix SQLAlchemy
2024-11-30 22:07:51 -05:00
epenetandGitHub 44f715bd02 Use issue_registry fixture in component tests (#118041) 2024-05-24 15:54:20 +02:00
6bb4e7d62c Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <[email protected]>
Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
2024-03-26 00:02:16 +01:00
J. Nick KostonandGitHub 65358c129a Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
Marc MuellerandGitHub 7d6251ca08 Add empty line after module docstring [tests q-s] (#112711) 2024-03-08 14:47:22 +01:00
G JohanssonandGitHub 5073842514 Fix sql integration no recorder (#111263) 2024-02-24 22:40:49 +01:00
Jan-Philipp BeneckeandGitHub 33dd6f66e3 Correct device class in sql tests (#107663) 2024-01-09 16:30:21 +01:00
65c21438a6 Add query type validation independent of declaration position for SQL (#105921)
* Add query type validation independent of declaration position

* Restore close sess

* Separates invalid query and non-read-only query tests

* Add more tests

* Use the SQLParseError exception for queries that are not read-only

* Add handling for multiple SQL queries.

* Fix test

* Clean ';' at the beginning of the SQL query

* Clean ';' at the beginning of the SQL query - init

* Query cleaning before storing

* Query cleaning before setup sesensor plataform - YAML

* Exception when the SQL query type is not detected

* Cleaning

* Cleaning

* Fix typing in tests

* Fix typing in tests

* Add test for query = ';;'

* Update homeassistant/components/sql/__init__.py

Co-authored-by: G Johansson <[email protected]>

* Update homeassistant/components/sql/__init__.py

Co-authored-by: G Johansson <[email protected]>

* Update __init__.py

* Update config_flow.py

* Clean query before storing

---------

Co-authored-by: G Johansson <[email protected]>
2023-12-27 17:58:35 +01:00
G JohanssonandGitHub 99cf4a6b2d Add rollback on exception that needs rollback in SQL (#104948) 2023-12-08 21:13:37 +01:00
Marc MuellerandGitHub 735b5cf1a0 Fix sql test warning (#99556) 2023-09-03 19:58:13 -05:00
G JohanssonandGitHub 4e2b00a443 Refactor SQL with ManualTriggerEntity (#95116)
* First go

* Finalize sensor

* Add tests

* Remove not need _attr_name

* device_class

* _process_manual_data allow Any as value
2023-07-20 11:35:08 +02:00
dougiteixeiraandGitHub 4b1d096e6b Add device_class and state_class in config flow for SQL (#95020)
* Add device_class and state_class in config flow for SQL

* Update when selected NONE_SENTINEL

* Add tests

* Use SensorDeviceClass and SensorStateClass in tests

* Add volatile_organic_compounds_parts in strings selector

* Add test_attributes_from_entry_config

* Remove test_attributes_from_entry_config and complement test_device_state_class

* Add test_attributes_from_entry_config in test_sensor.py
2023-07-08 21:00:22 +02:00
Ville SkyttäandGitHub 940942a74a Import util.dt as dt_util in components/[p-s]* (#93761) 2023-05-30 00:09:42 +03:00
J. Nick KostonandGitHub 4366f83ac8 Restore use of local timezone for MariaDB/MySQL in SQL integration (#91313)
* Use local timezone for recorder connection

The fix in #90335 had an unexpected side effect of
using UTC for the timezone since all recorder operations
use UTC. Since only sqlite much use the database executor
we can use a seperate connection pool which uses local time

This also ensures that the engines are disposed of
when Home Assistant is shutdown as previously we
did not cleanly disconnect

* coverage

* fix unclean shutdown in config flow

* tweaks
2023-04-12 20:24:55 -04:00
J. Nick KostonandGitHub 6e9fcbfec1 Fix false positive in SQL sensor full table scan check (#91134) 2023-04-09 19:45:08 -10:00
53d7e33607 Raise an issue for legacy SQL queries that will cause full table scans (#90971)
* Raise an issue for SQL queries that will cause full table scans

* Raise an issue for SQL queries that will cause full table scans

* Raise an issue for SQL queries that will cause full table scans

* Raise an issue for SQL queries that will cause full table scans

* Update homeassistant/components/sql/sensor.py

Co-authored-by: Paulus Schoutsen <[email protected]>

* coverage

---------

Co-authored-by: Paulus Schoutsen <[email protected]>
2023-04-07 22:32:36 -04:00
J. Nick KostonandGitHub 7098debe09 Fix sql doing I/O in the event loop at startup (#90335)
* Fix sql doing I/O in the event loop

* Fix sql doing I/O in the event loop

* no test query on main db

* fix mocking because it was targeting the recorder
2023-03-26 21:02:24 -04:00
J. Nick KostonandGitHub 2cb673db04 Handle bytes data in sql sensors (#89169) 2023-03-13 18:07:05 -10:00
afa58b80bd Default to recorder db for SQL integration (#85436)
Co-authored-by: J. Nick Koston <[email protected]>
2023-03-13 17:41:32 -10:00
G JohanssonandGitHub f4cda2dfda Add device_class and state_class to sql (#85418) 2023-03-05 20:30:42 +01:00
epenetandGitHub dab8557951 Add type hints to integration tests (part 21) (#88233) 2023-02-16 11:15:26 +01:00
Franck NijhofandGitHub ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
94519de8dd Upgrade SQLAlchemy to 2.0.2 (#86436)
Co-authored-by: J. Nick Koston <[email protected]>
2023-02-08 08:17:32 -06:00
Franck NijhofandGitHub 5e81d28116 Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
2a965a6e44 SQL reintroduce yaml support (#75205)
Co-authored-by: J. Nick Koston <[email protected]>
2023-01-07 18:14:36 -10:00
G JohanssonandGitHub a746d7c1d7 Improve code quality in sql integration (#71705) 2022-05-12 19:40:00 -04:00
c90eb4d6b4 Fix sql integration issues 5.0 beta (#71063)
Co-authored-by: Paulus Schoutsen <[email protected]>
2022-04-29 10:00:44 -07:00
G JohanssonandGitHub 472ffd3bc6 Implement config flow for SQL integration (#68700) 2022-04-24 08:50:32 -10:00
G JohanssonandGitHub 3f9a6bbaa7 Fix sql false warning (#67614) 2022-03-04 08:20:10 -10:00
G JohanssonandGitHub 8da150bd71 Improve code quality sql (#65321) 2022-02-12 08:13:01 -06:00
Diogo GomesandGitHub d5d8eefded Case sensitive SQL queries checks (#62752) 2022-01-07 17:19:30 +01:00
Erik MontnemeryandGitHub 2555b10d49 Remove login details before logging SQL errors (#48758) 2021-04-07 12:15:56 +02:00
Julian EngelhardtandGitHub 473afc4837 Rewrite SQL tests to pytest style (#41016)
* Remove unittests and common mock from SQL component tests

* Switch to async versions of setup_component and block_till_done
2020-10-03 03:42:50 +02:00
276f3afb00 Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <[email protected]>
2020-05-31 22:18:30 -07:00
Michał MrozekandFabian Affolter ed46834a30 Move imports in sql component (#27713)
* move imports in sql component

* fix: variable redeclaration

* fix: close test db session on platform setup
2019-10-20 10:10:27 +02:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
Penny WoodandPaulus Schoutsen f195ecca4b Consolidate all platforms that have tests (#22109)
* Moved climate components with tests into platform dirs.

* Updated tests from climate component.

* Moved binary_sensor components with tests into platform dirs.

* Updated tests from binary_sensor component.

* Moved calendar components with tests into platform dirs.

* Updated tests from calendar component.

* Moved camera components with tests into platform dirs.

* Updated tests from camera component.

* Moved cover components with tests into platform dirs.

* Updated tests from cover component.

* Moved device_tracker components with tests into platform dirs.

* Updated tests from device_tracker component.

* Moved fan components with tests into platform dirs.

* Updated tests from fan component.

* Moved geo_location components with tests into platform dirs.

* Updated tests from geo_location component.

* Moved image_processing components with tests into platform dirs.

* Updated tests from image_processing component.

* Moved light components with tests into platform dirs.

* Updated tests from light component.

* Moved lock components with tests into platform dirs.

* Moved media_player components with tests into platform dirs.

* Updated tests from media_player component.

* Moved scene components with tests into platform dirs.

* Moved sensor components with tests into platform dirs.

* Updated tests from sensor component.

* Moved switch components with tests into platform dirs.

* Updated tests from sensor component.

* Moved vacuum components with tests into platform dirs.

* Updated tests from vacuum component.

* Moved weather components with tests into platform dirs.

* Fixed __init__.py files

* Fixes for stuff moved as part of this branch.

* Fix stuff needed to merge with balloob's branch.

* Formatting issues.

* Missing __init__.py files.

* Fix-ups

* Fixup

* Regenerated requirements.

* Linting errors fixed.

* Fixed more broken tests.

* Missing init files.

* Fix broken tests.

* More broken tests

* There seems to be a thread race condition.
I suspect the logger stuff is running in another thread, which means waiting until the aio loop is done is missing the log messages.
Used sleep instead because that allows the logger thread to run. I think the api_streams sensor might not be thread safe.

* Disabled tests, will remove sensor in #22147

* Updated coverage and codeowners.
2019-03-18 23:07:39 -07:00