Default to recorder db for SQL integration (#85436)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
G Johansson 2023-03-14 04:41:32 +01:00 committed by GitHub
parent 2f4e9c8ef3
commit afa58b80bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 120 additions and 54 deletions

View file

@ -0,0 +1,25 @@
"""Test the sql utils."""
from unittest.mock import AsyncMock
from homeassistant.components.recorder import get_instance
from homeassistant.components.sql.util import resolve_db_url
from homeassistant.core import HomeAssistant
async def test_resolve_db_url_when_none_configured(
recorder_mock: AsyncMock,
hass: HomeAssistant,
):
"""Test return recorder db_url if provided db_url is None."""
db_url = None
resolved_url = resolve_db_url(hass, db_url)
assert resolved_url == get_instance(hass).db_url
async def test_resolve_db_url_when_configured(hass: HomeAssistant):
"""Test return provided db_url if it's set."""
db_url = "mssql://"
resolved_url = resolve_db_url(hass, db_url)
assert resolved_url == db_url