def test_config_component_platform_fail_validation(self, mock_get_loop): """Test errors if component & platform not found.""" files = { 'component.yaml': BASE_CONFIG + 'http:\n password: err123', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('component.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {}, 'except': {'http': {'password': '******'}}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../component.yaml'] }, res) files = { 'platform.yaml': (BASE_CONFIG + 'mqtt:\n\n' 'light:\n platform: mqtt_json'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('platform.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {'mqtt': {'keepalive': 60, 'port': 1883, 'protocol': '3.1.1'}}, 'except': {'light.mqtt_json': {'platform': 'mqtt_json'}}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../platform.yaml'] }, res)
def test_component_platform_not_found(self): """Test errors if component or platform not found.""" files = { 'badcomponent.yaml': BASE_CONFIG + 'beer:', 'badplatform.yaml': BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('badcomponent.yaml')) change_yaml_files(res) self.assertDictEqual( { 'components': {}, 'except': { check_config.ERROR_STR: ['Component not found: beer'] }, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../badcomponent.yaml'] }, res) res = check_config.check(get_test_config_dir('badplatform.yaml')) change_yaml_files(res) self.assertDictEqual( { 'components': {}, 'except': { check_config.ERROR_STR: ['Platform not found: light.beer'] }, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../badplatform.yaml'] }, res)
def test_config_component_platform_fail_validation(self): """Test errors if component & platform not found.""" files = { 'component.yaml': BASE_CONFIG + 'http:\n password: err123', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('component.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {}, 'except': {'http': {'password': '******'}}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../component.yaml'] }, res) files = { 'platform.yaml': (BASE_CONFIG + 'mqtt:\n\n' 'light:\n platform: mqtt_json'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('platform.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {'mqtt': {'keepalive': 60, 'port': 1883, 'protocol': '3.1.1'}}, 'except': {'light.mqtt_json': {'platform': 'mqtt_json'}}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../platform.yaml'] }, res)
def test_component_platform_not_found(self, isfile_patch): """Test errors if component or platform not found.""" # Make sure they don't exist set_component('beer', None) files = { YAML_CONFIG_FILE: BASE_CONFIG + 'beer:', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant'} assert res['except'] == { check_config.ERROR_STR: ['Component not found: beer']} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1 set_component('light.beer', None) files = { YAML_CONFIG_FILE: BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant', 'light'} assert res['components']['light'] == [] assert res['except'] == { check_config.ERROR_STR: [ 'Platform not found: light.beer', ]} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_component_platform_not_found(self, mock_get_loop): """Test errors if component or platform not found.""" files = { 'badcomponent.yaml': BASE_CONFIG + 'beer:', 'badplatform.yaml': BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('badcomponent.yaml')) change_yaml_files(res) self.assertDictEqual({}, res['components']) self.assertDictEqual({check_config.ERROR_STR: ['Component not found: beer']}, res['except']) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files']) res = check_config.check(get_test_config_dir('badplatform.yaml')) change_yaml_files(res) self.assertDictEqual({'light': []}, res['components']) self.assertDictEqual({check_config.ERROR_STR: ['Platform not found: light.beer']}, res['except']) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badplatform.yaml'], res['yaml_files'])
def test_component_platform_not_found(self): """Test errors if component or platform not found.""" # Make sure they don't exist set_component('beer', None) set_component('light.beer', None) files = { 'badcomponent.yaml': BASE_CONFIG + 'beer:', 'badplatform.yaml': BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('badcomponent.yaml')) change_yaml_files(res) self.assertDictEqual({}, res['components']) self.assertDictEqual({ check_config.ERROR_STR: [ 'Component not found: beer', 'Setup failed for beer: Component not found.'] }, res['except']) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files']) res = check_config.check(get_test_config_dir('badplatform.yaml')) change_yaml_files(res) assert res['components'] == {'light': [], 'group': None} assert res['except'] == { check_config.ERROR_STR: [ 'Platform not found: light.beer', ]} self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badplatform.yaml'], res['yaml_files'])
def test_component_platform_not_found(self, isfile_patch): """Test errors if component or platform not found.""" # Make sure they don't exist files = { YAML_CONFIG_FILE: BASE_CONFIG + 'beer:', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant'} assert res['except'] == { check_config.ERROR_STR: ['Component not found: beer'] } assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1 files = { YAML_CONFIG_FILE: BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant', 'light'} assert res['components']['light'] == [] assert res['except'] == { check_config.ERROR_STR: [ 'Platform not found: light.beer', ] } assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_component_platform_not_found(self): """Test errors if component or platform not found.""" files = { 'badcomponent.yaml': BASE_CONFIG + 'beer:', 'badplatform.yaml': BASE_CONFIG + 'light:\n platform: beer', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('badcomponent.yaml')) change_yaml_files(res) self.assertDictEqual({}, res['components']) self.assertDictEqual( { check_config.ERROR_STR: [ 'Component not found: beer', 'Setup failed for beer: Component not found.' ] }, res['except']) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badcomponent.yaml'], res['yaml_files']) res = check_config.check(get_test_config_dir('badplatform.yaml')) change_yaml_files(res) assert res['components'] == {'light': []} assert res['except'] == { check_config.ERROR_STR: [ 'Platform not found: light.beer', ] } self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../badplatform.yaml'], res['yaml_files'])
def test_component_platform_not_found(isfile_patch, loop): """Test errors if component or platform not found.""" # Make sure they don't exist files = {YAML_CONFIG_FILE: BASE_CONFIG + "beer:"} with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res["components"].keys() == {"homeassistant"} assert res["except"] == { check_config.ERROR_STR: ["Component error: beer - Integration 'beer' not found."] } assert res["secret_cache"] == {} assert res["secrets"] == {} assert len(res["yaml_files"]) == 1 files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"} with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res["components"].keys() == {"homeassistant", "light"} assert res["components"]["light"] == [] assert res["except"] == { check_config.ERROR_STR: ["Platform error light.beer - Integration 'beer' not found."] } assert res["secret_cache"] == {} assert res["secrets"] == {} assert len(res["yaml_files"]) == 1
def test_secrets(isfile_patch, loop): """Test secrets config checking method.""" secrets_path = get_test_config_dir("secrets.yaml") files = { get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG + ("http:\n cors_allowed_origins: !secret http_pw"), secrets_path: ("logger: debug\nhttp_pw: http://google.com"), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir(), True) assert res["except"] == {} assert res["components"].keys() == {"homeassistant", "http"} assert res["components"]["http"] == { "cors_allowed_origins": ["http://google.com"], "ip_ban_enabled": True, "login_attempts_threshold": -1, "server_port": 8123, "ssl_profile": "modern", } assert res["secret_cache"] == { secrets_path: { "http_pw": "http://google.com" } } assert res["secrets"] == {"http_pw": "http://google.com"} assert normalize_yaml_files(res) == [ ".../configuration.yaml", ".../secrets.yaml", ]
def test_secrets(self, mock_get_loop): """Test secrets config checking method.""" files = { get_test_config_dir('secret.yaml'): ( BASE_CONFIG + 'http:\n' ' api_password: !secret http_pw'), 'secrets.yaml': ('logger: debug\n' 'http_pw: abc123'), } self.maxDiff = None with patch_yaml_files(files): config_path = get_test_config_dir('secret.yaml') secrets_path = get_test_config_dir('secrets.yaml') res = check_config.check(config_path) change_yaml_files(res) # convert secrets OrderedDict to dict for assertequal for key, val in res['secret_cache'].items(): res['secret_cache'][key] = dict(val) self.assertDictEqual({ 'components': {'http': {'api_password': '******', 'server_port': 8123}}, 'except': {}, 'secret_cache': {secrets_path: {'http_pw': 'abc123'}}, 'secrets': {'http_pw': 'abc123'}, 'yaml_files': ['.../secret.yaml', '.../secrets.yaml'] }, res)
def test_secrets(self, isfile_patch): """Test secrets config checking method.""" secrets_path = get_test_config_dir('secrets.yaml') files = { get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG + ('http:\n' ' api_password: !secret http_pw'), secrets_path: ('logger: debug\n' 'http_pw: abc123'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir(), True) assert res['except'] == {} assert res['components'].keys() == {'homeassistant', 'http'} assert res['components']['http'] == { 'api_password': '******', 'cors_allowed_origins': [], 'ip_ban_enabled': True, 'login_attempts_threshold': -1, 'server_host': '0.0.0.0', 'server_port': 8123, 'trusted_networks': [], 'ssl_profile': 'modern', } assert res['secret_cache'] == {secrets_path: {'http_pw': 'abc123'}} assert res['secrets'] == {'http_pw': 'abc123'} assert normalize_yaml_files(res) == [ '.../configuration.yaml', '.../secrets.yaml' ]
def test_bad_core_config(isfile_patch, loop): """Test a bad core config setup.""" files = {YAML_CONFIG_FILE: BAD_CORE_CONFIG} with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res["except"].keys() == {"homeassistant"} assert res["except"]["homeassistant"][1] == {"unit_system": "bad"}
def test_secrets(self, isfile_patch): """Test secrets config checking method.""" secrets_path = get_test_config_dir('secrets.yaml') files = { get_test_config_dir(YAML_CONFIG_FILE): BASE_CONFIG + ( 'http:\n' ' api_password: !secret http_pw'), secrets_path: ( 'logger: debug\n' 'http_pw: abc123'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir(), True) assert res['except'] == {} assert res['components'].keys() == {'homeassistant', 'http'} assert res['components']['http'] == { 'api_password': '******', 'cors_allowed_origins': [], 'ip_ban_enabled': True, 'login_attempts_threshold': -1, 'server_host': '0.0.0.0', 'server_port': 8123, 'trusted_networks': [], 'use_x_forwarded_for': False} assert res['secret_cache'] == {secrets_path: {'http_pw': 'abc123'}} assert res['secrets'] == {'http_pw': 'abc123'} assert normalize_yaml_files(res) == [ '.../configuration.yaml', '.../secrets.yaml']
def test_config_component_platform_fail_validation(self): """Test errors if component & platform not found.""" files = { 'component.yaml': BASE_CONFIG + 'http:\n password: err123', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('component.yaml')) change_yaml_files(res) self.assertDictEqual({}, res['components']) res['except'].pop(check_config.ERROR_STR) self.assertDictEqual( {'http': {'password': '******'}}, res['except'] ) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../component.yaml'], res['yaml_files']) files = { 'platform.yaml': (BASE_CONFIG + 'mqtt:\n\n' 'light:\n platform: mqtt_json'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('platform.yaml')) change_yaml_files(res) self.assertDictEqual( {'mqtt': { 'keepalive': 60, 'port': 1883, 'protocol': '3.1.1', 'discovery': False, 'discovery_prefix': 'homeassistant', 'tls_version': 'auto', }, 'light': [], 'group': None}, res['components'] ) self.assertDictEqual( {'light.mqtt_json': {'platform': 'mqtt_json'}}, res['except'] ) self.assertDictEqual({}, res['secret_cache']) self.assertDictEqual({}, res['secrets']) self.assertListEqual(['.../platform.yaml'], res['yaml_files'])
def test_bad_core_config(self, isfile_patch): """Test a bad core config setup.""" files = { YAML_CONFIG_FILE: BAD_CORE_CONFIG, } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['except'].keys() == {'homeassistant'} assert res['except']['homeassistant'][1] == {'unit_system': 'bad'}
def test_config_platform_valid(isfile_patch, loop): """Test a valid platform setup.""" files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: demo"} with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res["components"].keys() == {"homeassistant", "light"} assert res["components"]["light"] == [{"platform": "demo"}] assert res["except"] == {} assert res["secret_cache"] == {} assert res["secrets"] == {} assert len(res["yaml_files"]) == 1
def test_bootstrap_error(loop): """Test a valid platform setup.""" files = {YAML_CONFIG_FILE: BASE_CONFIG + "automation: !include no.yaml"} with patch_yaml_files(files): res = check_config.check(get_test_config_dir(YAML_CONFIG_FILE)) err = res["except"].pop(check_config.ERROR_STR) assert len(err) == 1 assert res["except"] == {} assert res["components"] == {} # No components, load failed assert res["secret_cache"] == {} assert res["secrets"] == {} assert res["yaml_files"] == {}
def test_config_platform_valid(self, isfile_patch): """Test a valid platform setup.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + 'light:\n platform: demo', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant', 'light'} assert res['components']['light'] == [{'platform': 'demo'}] assert res['except'] == {} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_config_component_platform_fail_validation(self, isfile_patch): """Test errors if component & platform not found.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + 'http:\n password: err123', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant'} assert res['except'].keys() == {'http'} assert res['except']['http'][1] == {'http': {'password': '******'}} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1 files = { YAML_CONFIG_FILE: (BASE_CONFIG + 'mqtt:\n\n' 'light:\n platform: mqtt_json'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == { 'homeassistant', 'light', 'mqtt' } assert res['components']['light'] == [] assert res['components']['mqtt'] == { 'keepalive': 60, 'port': 1883, 'protocol': '3.1.1', 'discovery': False, 'discovery_prefix': 'homeassistant', 'tls_version': 'auto', } assert res['except'].keys() == {'light.mqtt_json'} assert res['except']['light.mqtt_json'][1] == { 'platform': 'mqtt_json' } assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_bootstrap_error(self): """Test a valid platform setup.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + 'automation: !include no.yaml', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir(YAML_CONFIG_FILE)) err = res['except'].pop(check_config.ERROR_STR) assert len(err) == 1 assert res['except'] == {} assert res['components'] == {} # No components, load failed assert res['secret_cache'] == {} assert res['secrets'] == {} assert res['yaml_files'] == {}
def test_secrets(self): """Test secrets config checking method.""" files = { get_test_config_dir('secret.yaml'): (BASE_CONFIG + 'http:\n' ' api_password: !secret http_pw'), 'secrets.yaml': ('logger: debug\n' 'http_pw: abc123'), } self.maxDiff = None with patch_yaml_files(files): config_path = get_test_config_dir('secret.yaml') secrets_path = get_test_config_dir('secrets.yaml') res = check_config.check(config_path) change_yaml_files(res) # convert secrets OrderedDict to dict for assertequal for key, val in res['secret_cache'].items(): res['secret_cache'][key] = dict(val) self.assertDictEqual( { 'components': { 'http': { 'api_password': '******', 'cors_allowed_origins': [], 'development': '0', 'ip_ban_enabled': True, 'login_attempts_threshold': -1, 'server_host': '0.0.0.0', 'server_port': 8123, 'ssl_certificate': None, 'ssl_key': None, 'trusted_networks': [], 'use_x_forwarded_for': False } }, 'except': {}, 'secret_cache': { secrets_path: { 'http_pw': 'abc123' } }, 'secrets': { 'http_pw': 'abc123' }, 'yaml_files': ['.../secret.yaml', '.../secrets.yaml'] }, res)
def test_config_component_platform_fail_validation(self, isfile_patch): """Test errors if component & platform not found.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + 'http:\n password: err123', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == {'homeassistant'} assert res['except'].keys() == {'http'} assert res['except']['http'][1] == {'http': {'password': '******'}} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1 files = { YAML_CONFIG_FILE: (BASE_CONFIG + 'mqtt:\n\n' 'light:\n platform: mqtt_json'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['components'].keys() == { 'homeassistant', 'light', 'mqtt'} assert res['components']['light'] == [] assert res['components']['mqtt'] == { 'keepalive': 60, 'port': 1883, 'protocol': '3.1.1', 'discovery': False, 'discovery_prefix': 'homeassistant', 'tls_version': 'auto', } assert res['except'].keys() == {'light.mqtt_json'} assert res['except']['light.mqtt_json'][1] == { 'platform': 'mqtt_json'} assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_config_platform_valid(self): """Test a valid platform setup.""" files = { 'light.yaml': BASE_CONFIG + 'light:\n platform: demo', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('light.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {'light': [{'platform': 'demo'}]}, 'except': {}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../light.yaml'] }, res)
def test_config_platform_valid(self, mock_get_loop): """Test a valid platform setup.""" files = { 'light.yaml': BASE_CONFIG + 'light:\n platform: demo', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('light.yaml')) change_yaml_files(res) self.assertDictEqual({ 'components': {'light': [{'platform': 'demo'}]}, 'except': {}, 'secret_cache': {}, 'secrets': {}, 'yaml_files': ['.../light.yaml'] }, res)
def test_package_invalid(isfile_patch, loop): """Test an invalid package.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + (" packages:\n p1:\n" ' group: ["a"]') } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res["except"].keys() == {"homeassistant.packages.p1.group"} assert res["except"]["homeassistant.packages.p1.group"][1] == {"group": ["a"]} assert len(res["except"]) == 1 assert res["components"].keys() == {"homeassistant"} assert len(res["components"]) == 1 assert res["secret_cache"] == {} assert res["secrets"] == {} assert len(res["yaml_files"]) == 1
def test_bootstrap_error(self): \ # pylint: disable=no-self-use,invalid-name """Test a valid platform setup.""" files = { 'badbootstrap.yaml': BASE_CONFIG + 'automation: !include no.yaml', } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('badbootstrap.yaml')) change_yaml_files(res) err = res['except'].pop(check_config.ERROR_STR) assert len(err) == 1 assert res['except'] == {} assert res['components'] == {} assert res['secret_cache'] == {} assert res['secrets'] == {}
def test_package_invalid(self, isfile_patch): """Test a valid platform setup.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + ( ' packages:\n' ' p1:\n' ' group: ["a"]'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['except'].keys() == {'homeassistant.packages.p1.group'} assert res['except']['homeassistant.packages.p1.group'][1] == \ {'group': ['a']} assert len(res['except']) == 1 assert res['components'].keys() == {'homeassistant'} assert len(res['components']) == 1 assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_package_invalid(self): \ # pylint: disable=no-self-use,invalid-name """Test a valid platform setup.""" files = { 'bad.yaml': BASE_CONFIG + (' packages:\n' ' p1:\n' ' group: ["a"]'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir('bad.yaml')) change_yaml_files(res) err = res['except'].pop('homeassistant.packages.p1') assert res['except'] == {} assert err == {'group': ['a']} assert res['yaml_files'] == ['.../bad.yaml'] assert res['components'] == {} assert res['secret_cache'] == {} assert res['secrets'] == {}
def test_package_invalid(self, isfile_patch): """Test a valid platform setup.""" files = { YAML_CONFIG_FILE: BASE_CONFIG + (' packages:\n' ' p1:\n' ' group: ["a"]'), } with patch_yaml_files(files): res = check_config.check(get_test_config_dir()) assert res['except'].keys() == {'homeassistant.packages.p1.group'} assert res['except']['homeassistant.packages.p1.group'][1] == \ {'group': ['a']} assert len(res['except']) == 1 assert res['components'].keys() == {'homeassistant'} assert len(res['components']) == 1 assert res['secret_cache'] == {} assert res['secrets'] == {} assert len(res['yaml_files']) == 1
def test_secrets(self): """Test secrets config checking method.""" files = { get_test_config_dir('secret.yaml'): ( BASE_CONFIG + 'http:\n' ' api_password: !secret http_pw'), 'secrets.yaml': ('logger: debug\n' 'http_pw: abc123'), } self.maxDiff = None with patch_yaml_files(files): config_path = get_test_config_dir('secret.yaml') secrets_path = get_test_config_dir('secrets.yaml') res = check_config.check(config_path) change_yaml_files(res) # convert secrets OrderedDict to dict for assertequal for key, val in res['secret_cache'].items(): res['secret_cache'][key] = dict(val) self.assertDictEqual({ 'components': {'http': {'api_password': '******', 'cors_allowed_origins': [], 'development': '0', 'ip_ban_enabled': True, 'login_attempts_threshold': -1, 'server_host': '0.0.0.0', 'server_port': 8123, 'ssl_certificate': None, 'ssl_key': None, 'trusted_networks': [], 'use_x_forwarded_for': False}}, 'except': {}, 'secret_cache': {secrets_path: {'http_pw': 'abc123'}}, 'secrets': {'http_pw': 'abc123'}, 'yaml_files': ['.../secret.yaml', '.../secrets.yaml'] }, res)