From b70be5f2f232b18bb4db2e4041f5aa96385c121e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 17 Mar 2020 12:14:17 -0700 Subject: [PATCH] Blacklist auto_backup (#32912) * Blacklist auto_backup * Mock with a set --- homeassistant/setup.py | 8 ++++++++ tests/test_setup.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/homeassistant/setup.py b/homeassistant/setup.py index f62228b28f5..e00c5fac03f 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -19,6 +19,8 @@ DATA_DEPS_REQS = "deps_reqs_processed" SLOW_SETUP_WARNING = 10 +BLACKLIST = set(["auto_backup"]) + def setup_component(hass: core.HomeAssistant, domain: str, config: Dict) -> bool: """Set up a component and all its dependencies.""" @@ -37,6 +39,12 @@ async def async_setup_component( if domain in hass.config.components: return True + if domain in BLACKLIST: + _LOGGER.error( + "Integration %s is blacklisted because it is causing issues.", domain + ) + return False + setup_tasks = hass.data.setdefault(DATA_SETUP, {}) if domain in setup_tasks: diff --git a/tests/test_setup.py b/tests/test_setup.py index f90a7269752..95fd1e0a15d 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -6,6 +6,7 @@ import os import threading from unittest import mock +from asynctest import patch import voluptuous as vol from homeassistant import setup @@ -535,3 +536,15 @@ async def test_setup_import_blows_up(hass): "homeassistant.loader.Integration.get_component", side_effect=ValueError ): assert not await setup.async_setup_component(hass, "sun", {}) + + +async def test_blacklist(caplog): + """Test setup blacklist.""" + with patch("homeassistant.setup.BLACKLIST", {"bad_integration"}): + assert not await setup.async_setup_component( + mock.Mock(config=mock.Mock(components=[])), "bad_integration", {} + ) + assert ( + "Integration bad_integration is blacklisted because it is causing issues." + in caplog.text + )