added config loader

This commit is contained in:
Ari Sosnovsky committed 2021-11-10 12:46:30 -05:00
1 parent c794661e05
commit 12b4ff6615
10 files changed
+263 -119

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
from unittest import TestCase
from src.config.HassSafeConstructor import SecretValue, load_hass_config, IncludedYaml
from tests.utils import SAMPLE_HA_PATH
class config_finder_tests(TestCase):
def test_find_sample_config(self):
secrets, config = load_hass_config(SAMPLE_HA_PATH)
self.assertIsInstance(config["template"], IncludedYaml)
self.assertIsInstance(config["binary_sensor"], IncludedYaml)
self.assertIsInstance(config["group"], IncludedYaml)
self.assertIsInstance(config["switch"], IncludedYaml)
self.assertEqual(secrets["myamazingpassword"], "holymoly")
self.assertEqual(
config["automation"].data[32]["trigger"][0]["device_id"],
SecretValue("baby_btn_device_id", "347492ffc6b909a55ebe08745fca1bf6"),
)
+1 -3
View File
@@ -1,10 +1,8 @@
from pathlib import Path
from unittest import TestCase
from src.db.connection import HassDatabase
from src.db import entities
from tests.utils import SAMPLE_DB_PATH
THIS_FOLDER = Path(__file__).parent
SAMPLE_DB_PATH = THIS_FOLDER.parent / "samples" / "home-assistant_v2.db"
db = HassDatabase(f"sqlite:///{SAMPLE_DB_PATH.absolute()}")
+5
View File
@@ -0,0 +1,5 @@
from pathlib import Path
THIS_FOLDER = Path(__file__).parent
SAMPLE_HA_PATH = THIS_FOLDER / "samples"
SAMPLE_DB_PATH = SAMPLE_HA_PATH / "home-assistant_v2.db"