From 4462f2fc46957cf7b47c595c8125cfdf85291aee Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 13 Oct 2022 11:44:48 +0200 Subject: [PATCH] Fix recorder tests related to mysql (#80238) --- tests/components/recorder/test_init.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/components/recorder/test_init.py b/tests/components/recorder/test_init.py index 977e32e9a71..54e82516373 100644 --- a/tests/components/recorder/test_init.py +++ b/tests/components/recorder/test_init.py @@ -1649,7 +1649,7 @@ async def test_disable_echo(hass, db_url, echo, caplog): @pytest.mark.parametrize( - "config_url, connect_args", + "config_url, expected_connect_args", ( ( "mariadb://user:password@SERVER_IP/DB_NAME", @@ -1677,15 +1677,15 @@ async def test_disable_echo(hass, db_url, echo, caplog): ), ( "postgresql://blabla", - None, + {}, ), ( "sqlite://blabla", - None, + {}, ), ), ) -async def test_mysql_missing_utf8mb4(hass, config_url, connect_args): +async def test_mysql_missing_utf8mb4(hass, config_url, expected_connect_args): """Test recorder fails to setup if charset=utf8mb4 is missing from db_url.""" recorder_helper.async_initialize_recorder(hass) @@ -1701,7 +1701,10 @@ async def test_mysql_missing_utf8mb4(hass, config_url, connect_args): ): await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_DB_URL: config_url}}) create_engine_mock.assert_called_once() - assert create_engine_mock.mock_calls[0][2].get("connect_args") == connect_args + + connect_args = create_engine_mock.mock_calls[0][2].get("connect_args", {}) + for key, value in expected_connect_args.items(): + assert connect_args[key] == value @pytest.mark.parametrize( @@ -1771,4 +1774,4 @@ async def test_connect_args_priority(hass, config_url): } }, ) - assert connect_params == [{"charset": "utf8mb4"}] + assert connect_params[0]["charset"] == "utf8mb4"