def main(): """Main section of the script.""" if not os.path.isfile("requirements_all.txt"): print("Run this from HA root dir") return msg = {} def add_msg(key, item): """Add a message.""" if key not in msg: msg[key] = [] msg[key].append(item) for package in explore_module("homeassistant.components"): module = importlib.import_module(package) module_name = getattr(module, "DOMAIN", module.__name__) if hasattr(module, "PLATFORM_SCHEMA"): if hasattr(module, "CONFIG_SCHEMA"): add_msg("WARNING", "Module {} contains PLATFORM and CONFIG " "schemas".format(module_name)) add_msg("PLATFORM SCHEMA", module_name) continue if not hasattr(module, "CONFIG_SCHEMA"): add_msg("NO SCHEMA", module_name) continue schema_type, schema = _identify_config_schema(module) add_msg("CONFIG_SCHEMA " + schema_type, module_name + " " + color("cyan", str(schema)[:60])) for key in sorted(msg): print("\n{}\n - {}".format(key, "\n - ".join(msg[key])))
def test_identify_config_schema(domain, schema, expected): """Test identify config schema.""" assert ( config_util._identify_config_schema(Mock(DOMAIN=domain, CONFIG_SCHEMA=schema))[ 0 ] == expected )
async def test_merge_id_schema(hass): """Test if we identify the config schemas correctly.""" types = { "panel_custom": "list", "group": "dict", "input_boolean": "dict", "shell_command": "dict", "qwikswitch": "dict", } for domain, expected_type in types.items(): integration = await async_get_integration(hass, domain) module = integration.get_component() typ = config_util._identify_config_schema(module) assert typ == expected_type, f"{domain} expected {expected_type}, got {typ}"
def test_merge_id_schema(hass): """Test if we identify the config schemas correctly.""" types = { 'panel_custom': 'list', 'group': 'dict', 'script': 'dict', 'input_boolean': 'dict', 'shell_command': 'dict', 'qwikswitch': 'dict', } for name, expected_type in types.items(): module = config_util.get_component(hass, name) typ, _ = config_util._identify_config_schema(module) assert typ == expected_type, "{} expected {}, got {}".format( name, expected_type, typ)
def test_merge_id_schema(hass): """Test if we identify the config schemas correctly.""" types = { 'panel_custom': 'list', 'group': 'dict', 'script': 'dict', 'input_boolean': 'dict', 'shell_command': 'dict', 'qwikswitch': '', } for name, expected_type in types.items(): module = config_util.get_component(name) typ, _ = config_util._identify_config_schema(module) assert typ == expected_type, "{} expected {}, got {}".format( name, expected_type, typ)
async def test_merge_id_schema(hass): """Test if we identify the config schemas correctly.""" types = { 'panel_custom': 'list', 'group': 'dict', 'script': 'dict', 'input_boolean': 'dict', 'shell_command': 'dict', 'qwikswitch': 'dict', } for domain, expected_type in types.items(): integration = await async_get_integration(hass, domain) module = integration.get_component() typ, _ = config_util._identify_config_schema(module) assert typ == expected_type, "{} expected {}, got {}".format( domain, expected_type, typ)
def main(): """Run the script.""" if not os.path.isfile("requirements_all.txt"): print("Run this from HA root dir") return msg = {} def add_msg(key, item): """Add a message.""" if key not in msg: msg[key] = [] msg[key].append(item) for package in explore_module("homeassistant.components"): module = importlib.import_module(package) module_name = getattr(module, "DOMAIN", module.__name__) if hasattr(module, "PLATFORM_SCHEMA"): if hasattr(module, "CONFIG_SCHEMA"): add_msg( "WARNING", "Module {} contains PLATFORM and CONFIG " "schemas".format(module_name), ) add_msg("PLATFORM SCHEMA", module_name) continue if not hasattr(module, "CONFIG_SCHEMA"): add_msg("NO SCHEMA", module_name) continue schema_type, schema = _identify_config_schema(module) add_msg( "CONFIG_SCHEMA " + str(schema_type), module_name + " " + color("cyan", str(schema)[:60]), ) for key in sorted(msg): print("\n{}\n - {}".format(key, "\n - ".join(msg[key])))
def main(): """Run the script.""" if not os.path.isfile('requirements_all.txt'): print('Run this from HA root dir') return msg = {} def add_msg(key, item): """Add a message.""" if key not in msg: msg[key] = [] msg[key].append(item) for package in explore_module('homeassistant.components'): module = importlib.import_module(package) module_name = getattr(module, 'DOMAIN', module.__name__) if hasattr(module, 'PLATFORM_SCHEMA'): if hasattr(module, 'CONFIG_SCHEMA'): add_msg( 'WARNING', "Module {} contains PLATFORM and CONFIG " "schemas".format(module_name)) add_msg('PLATFORM SCHEMA', module_name) continue if not hasattr(module, 'CONFIG_SCHEMA'): add_msg('NO SCHEMA', module_name) continue schema_type, schema = _identify_config_schema(module) add_msg("CONFIG_SCHEMA " + schema_type, module_name + ' ' + color('cyan', str(schema)[:60])) for key in sorted(msg): print("\n{}\n - {}".format(key, '\n - '.join(msg[key])))
def main(): """Run the script.""" if not os.path.isfile('requirements_all.txt'): print('Run this from HA root dir') return msg = {} def add_msg(key, item): """Add a message.""" if key not in msg: msg[key] = [] msg[key].append(item) for package in explore_module('homeassistant.components'): module = importlib.import_module(package) module_name = getattr(module, 'DOMAIN', module.__name__) if hasattr(module, 'PLATFORM_SCHEMA'): if hasattr(module, 'CONFIG_SCHEMA'): add_msg('WARNING', "Module {} contains PLATFORM and CONFIG " "schemas".format(module_name)) add_msg('PLATFORM SCHEMA', module_name) continue if not hasattr(module, 'CONFIG_SCHEMA'): add_msg('NO SCHEMA', module_name) continue schema_type, schema = _identify_config_schema(module) add_msg("CONFIG_SCHEMA " + schema_type, module_name + ' ' + color('cyan', str(schema)[:60])) for key in sorted(msg): print("\n{}\n - {}".format(key, '\n - '.join(msg[key])))