renamed to menu

This commit is contained in:
John Lancaster
2024-08-12 22:36:30 -05:00
parent e3873f5510
commit 4729bc2520
4 changed files with 16 additions and 12 deletions

View File

@@ -12,7 +12,7 @@ class GreenEggs(Eggs):
@dataclass
class Meal:
class Menu:
dishes: List[ADAPI] = field(init=False)
def __post_init__(self):

View File

@@ -1,11 +1,16 @@
from dataclasses import dataclass, field
from appdaemon.adapi import ADAPI
from food import Eggs
from food.meal import Meal
from food.menu import Menu
@dataclass(init=False)
class Restaurant(ADAPI):
menu: Menu = field(default=Menu)
def initialize(self):
meal = Meal()
eggs: Eggs = meal.dishes[0]
self.log(f"{self.__class__.__name__} initialized with {eggs}")
self.log(f"Last dish: {meal.dishes[-1]}")
self.log(f'{self.__class__.__name__} initialized')
log_str = ', '.join(f'{d.name}' for d in self.menu.dishes)
self.log(f'Menu: {log_str}')

View File

@@ -3,7 +3,7 @@ import logging
import re
from pathlib import Path
import food.meal
import food.menu
import pytest
from appdaemon.appdaemon import AppDaemon
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):
assert isinstance(ad, AppDaemon)
module_file = Path(food.meal.__file__)
module_file = Path(food.menu.__file__)
modify_file(module_file)
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):
assert isinstance(ad, AppDaemon)
module_file = Path(food.meal.__file__)
module_file = Path(food.menu.__file__)
insert_import_error(module_file)
try:

View File

@@ -15,8 +15,7 @@ def validate_app_dependencies(ad: AppDaemon):
def validate_module_dependencies(ad: AppDaemon):
graph = ad.app_management.module_dependencies
assert 'food' in graph['restaurant']
assert 'food.meal' in graph['restaurant']
assert 'food.menu' in graph['restaurant']
def validate_module_load_order(ad: AppDaemon, module_load_order: List[str]):