renamed to menu
This commit is contained in:
@@ -12,7 +12,7 @@ class GreenEggs(Eggs):
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Meal:
|
class Menu:
|
||||||
dishes: List[ADAPI] = field(init=False)
|
dishes: List[ADAPI] = field(init=False)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
from appdaemon.adapi import ADAPI
|
from appdaemon.adapi import ADAPI
|
||||||
from food import Eggs
|
from food.menu import Menu
|
||||||
from food.meal import Meal
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(init=False)
|
||||||
class Restaurant(ADAPI):
|
class Restaurant(ADAPI):
|
||||||
|
menu: Menu = field(default=Menu)
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
meal = Meal()
|
self.log(f'{self.__class__.__name__} initialized')
|
||||||
eggs: Eggs = meal.dishes[0]
|
|
||||||
self.log(f"{self.__class__.__name__} initialized with {eggs}")
|
log_str = ', '.join(f'{d.name}' for d in self.menu.dishes)
|
||||||
self.log(f"Last dish: {meal.dishes[-1]}")
|
|
||||||
|
self.log(f'Menu: {log_str}')
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import food.meal
|
import food.menu
|
||||||
import pytest
|
import pytest
|
||||||
from appdaemon.appdaemon import AppDaemon
|
from appdaemon.appdaemon import AppDaemon
|
||||||
from git import Repo
|
from git import Repo
|
||||||
@@ -33,7 +33,7 @@ def insert_import_error(path: Path):
|
|||||||
def test_file(ad: AppDaemon, caplog: pytest.LogCaptureFixture, config_repo: Repo):
|
def test_file(ad: AppDaemon, caplog: pytest.LogCaptureFixture, config_repo: Repo):
|
||||||
assert isinstance(ad, AppDaemon)
|
assert isinstance(ad, AppDaemon)
|
||||||
|
|
||||||
module_file = Path(food.meal.__file__)
|
module_file = Path(food.menu.__file__)
|
||||||
modify_file(module_file)
|
modify_file(module_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -52,7 +52,7 @@ def test_file(ad: AppDaemon, caplog: pytest.LogCaptureFixture, config_repo: Repo
|
|||||||
def test_file_with_error(ad: AppDaemon, caplog: pytest.LogCaptureFixture, config_repo: Repo):
|
def test_file_with_error(ad: AppDaemon, caplog: pytest.LogCaptureFixture, config_repo: Repo):
|
||||||
assert isinstance(ad, AppDaemon)
|
assert isinstance(ad, AppDaemon)
|
||||||
|
|
||||||
module_file = Path(food.meal.__file__)
|
module_file = Path(food.menu.__file__)
|
||||||
insert_import_error(module_file)
|
insert_import_error(module_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ def validate_app_dependencies(ad: AppDaemon):
|
|||||||
|
|
||||||
def validate_module_dependencies(ad: AppDaemon):
|
def validate_module_dependencies(ad: AppDaemon):
|
||||||
graph = ad.app_management.module_dependencies
|
graph = ad.app_management.module_dependencies
|
||||||
assert 'food' in graph['restaurant']
|
assert 'food.menu' in graph['restaurant']
|
||||||
assert 'food.meal' in graph['restaurant']
|
|
||||||
|
|
||||||
|
|
||||||
def validate_module_load_order(ad: AppDaemon, module_load_order: List[str]):
|
def validate_module_load_order(ad: AppDaemon, module_load_order: List[str]):
|
||||||
|
|||||||
Reference in New Issue
Block a user