initial test for actions

This commit is contained in:
Ari Sosnovsky committed 2021-11-10 15:27:52 -05:00
1 parent 5169cfbca9
commit 862ec58193
2 files changed
+28 -4

No files matched your search

+25
View File
@@ -6,6 +6,7 @@ from src.config.AutomationLoader import (
AutomationMetdata,
load_automation,
_parse_conditions,
_parse_actions,
)
from src.json_serializer import NOT_IMPLEMENTED_SV_MSG
from src.config.HassSafeConstructor import SecretValue, load_hass_config, IncludedYaml
@@ -51,6 +52,30 @@ class config_finder_tests(TestCase):
):
self.assertEqual(parsed, expected)
def test_various_action_types(self):
raw_conditions = [
{"condition": "template", "value_template": "silly logic here"},
"silly logic here",
{"condition": "time", "after": "10:00:00", "weekday": ["mon", "tue"]},
]
expected_process = [
AutomationConditionNode(
condition="template",
condition_data={"value_template": "silly logic here"},
),
AutomationConditionNode(
condition="template",
condition_data={"value_template": "silly logic here"},
),
AutomationConditionNode(
condition="time",
condition_data={"after": "10:00:00", "weekday": ["mon", "tue"]},
),
]
for parsed, expected in zip(expected_process, _parse_actions(raw_conditions)):
self.assertEqual(parsed, expected)
def test_automation_loader(self):
auto = list(
load_automation(