ffplayout/tests/run_time_machine.py

37 lines
794 B
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2021-02-11 09:44:58 +01:00
"""
Test script, for simulating different date and time.
This is useful for testing the transition from one playlist to another,
specially when the day_start time is in the night.
"""
import datetime
import os
import sys
import time_machine
2021-03-01 12:50:44 +01:00
try:
from zoneinfo import ZoneInfo
except ImportError:
from backports.zoneinfo import ZoneInfo
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2021-02-11 09:28:15 +01:00
# set time zone
_TZ = ZoneInfo("Europe/Berlin")
# fake date and time
2021-03-24 15:11:04 +01:00
SOURCE_TIME = [2021, 2, 14, 23, 59, 0]
2021-02-11 09:28:15 +01:00
@time_machine.travel(datetime.datetime(*SOURCE_TIME, tzinfo=_TZ))
def run_in_time_machine():
desktop.output()
if __name__ == '__main__':
2021-02-09 16:29:58 +01:00
from ffplayout.output import desktop
run_in_time_machine()