def test_api_router_with_mqtt_client(): from feeder.util.feeder import APIRouterWithMQTTClient client = "client" broker = "broker" router = APIRouterWithMQTTClient() router.client = client router.broker = broker assert router.client == client assert router.broker == broker
DeviceTelemetryData, FeedingResult, HopperLevelRef, StoredRecipe, ) from feeder.api.models.feeder import ( TriggerFeeding, GenericResponse, FeedHistory, HopperLevel, Recipe, RawMQTTMessage, ) logger = logging.getLogger(__name__) router = APIRouterWithMQTTClient() @router.get("", response_model=List[Device]) @router.get("/", response_model=List[Device]) async def get_devices(): return [ check_connection(device, router.broker) for device in await KronosDevices.get() ] @router.get("/history", response_model=FeedHistory) async def get_history(size: int = 10, page: int = 1): count_all = await FeedingResult.count() history = await FeedingResult.get(offset=page * size, limit=size) return paginate_response(