Пример #1
0
def main(auto_on: bool, auto_off: bool, disable_from, enable_from,
         update_cycle, ignore_gpio):
    pin_5a = RPIG(pin=5)
    pin_6b = RPIG(pin=6)

    next_update = get_date_now() + timedelta(seconds=update_cycle)
    handle_socket = HandleSocket(on=run_on_script, off=run_off_script)
    while True:
        main_on_off_wrapper(disable_from=disable_from,
                            enable_from=enable_from,
                            auto_on=auto_on,
                            auto_off=auto_off,
                            handle_socket=handle_socket)

        print("Sleep" + str(update_cycle))
        time.sleep(update_cycle)
        print("End final")
Пример #2
0
    def test_screen_2_a(self):
        backlight_config = BacklightConfig(auto_on=True,
                                           auto_off=False,
                                           disable_from="00:00:00",
                                           enable_from="00:01:00",
                                           update_cycle=6,
                                           ignore_gpio=True,
                                           name="test")
        now = get_date_now(str_now="23:59:30")
        next_update = now + timedelta(seconds=backlight_config.update_cycle)

        mock_on = mock.Mock(return_value="mocked stuff")
        mock_off = mock.Mock(return_value="mocked stuff")
        mock_date_now = mock.Mock(return_value=now)
        main_on_off_wrapper(disable_from=backlight_config.disable_from,
                            enable_from=backlight_config.enable_from,
                            auto_on=backlight_config.auto_on,
                            auto_off=backlight_config.auto_off,
                            handle_screen=HandleScreen(on=mock_on,
                                                       off=mock_off),
                            get_now=mock_date_now)
        mock_on.assert_called()
        mock_off.assert_not_called()