Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
tts:
platform: google

group: !include groups.yaml
"""


Expand Down Expand Up @@ -147,8 +148,12 @@ def create_default_config(config_dir, detect_location=True):
Return path to new config file if success, None if failed.
This method needs to run in an executor.
"""
from homeassistant.components.config.group import (
CONFIG_PATH as GROUP_CONFIG_PATH)

config_path = os.path.join(config_dir, YAML_CONFIG_FILE)
version_path = os.path.join(config_dir, VERSION_FILE)
group_yaml_path = os.path.join(config_dir, GROUP_CONFIG_PATH)

info = {attr: default for attr, default, _, _ in DEFAULT_CORE_CONFIG}

Expand Down Expand Up @@ -187,6 +192,9 @@ def create_default_config(config_dir, detect_location=True):
with open(version_path, 'wt') as version_file:
version_file.write(__version__)

with open(group_yaml_path, 'w'):
pass

return config_path

except IOError:
Expand Down
10 changes: 9 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
from homeassistant.util import location as location_util, dt as dt_util
from homeassistant.util.async import run_coroutine_threadsafe
from homeassistant.helpers.entity import Entity
from homeassistant.components.config.group import (
CONFIG_PATH as GROUP_CONFIG_PATH)

from tests.common import (
get_test_config_dir, get_test_home_assistant, mock_coro)

CONFIG_DIR = get_test_config_dir()
YAML_PATH = os.path.join(CONFIG_DIR, config_util.YAML_CONFIG_FILE)
VERSION_PATH = os.path.join(CONFIG_DIR, config_util.VERSION_FILE)
GROUP_PATH = os.path.join(CONFIG_DIR, GROUP_CONFIG_PATH)
ORIG_TIMEZONE = dt_util.DEFAULT_TIME_ZONE


Expand Down Expand Up @@ -51,13 +54,18 @@ def tearDown(self):
if os.path.isfile(VERSION_PATH):
os.remove(VERSION_PATH)

if os.path.isfile(GROUP_PATH):
os.remove(GROUP_PATH)

self.hass.stop()

def test_create_default_config(self):
"""Test creation of default config."""
config_util.create_default_config(CONFIG_DIR, False)

self.assertTrue(os.path.isfile(YAML_PATH))
assert os.path.isfile(YAML_PATH)
assert os.path.isfile(VERSION_PATH)
assert os.path.isfile(GROUP_PATH)

def test_find_config_file_yaml(self):
"""Test if it finds a YAML config file."""
Expand Down