def testrun(setting): print('Start test run.') print('Initialize eventcheckers.') eventcheckers = load_components(setting, 'eventchecker') print('OK\n') print('Initialize notifiers.') notifiers = load_components(setting, 'notifier') print('OK\n') print('Initialize recorders.') recorders = load_components(setting, 'recorder') print('OK\n') print('Initialize error handler.') err_handler = ErrorHandler(setting, notifiers) print('OK\n') print('Start checking if owner is at home.') resource_controller = ResourceController(setting) resource_controller.start_auto_switch() resource_controller.start_webserver() print('OK\n') print('Run event checks.') for checker in eventcheckers: checker.check() print('OK\n') print('Run notifications.') for notifier in notifiers: notifier.start_notification('test', 'Test notification from home-recorder') for notifier in notifiers: notifier.join() print('OK\n') print('Run recorders.') for recorder in recorders: recorder.start_recording('test', 5) for recorder in recorders: recorder.join() print('OK\n') print('Run error notification for 2 times.') err_handler.handle('test', 'Test notification from home-recorder') err_handler.handle('test', 'Test notification from home-recorder') print('OK\n') print('Stop checking if owner is at home.') resource_controller.stop_auto_switch() resource_controller.stop_webserver() print('OK\n') print('All components are OK.')