Files
ViewIT/tests/test_serienstream_perf.py
itdrui.de 7b60b00c8b dev: umfangreiches Refactoring, Trakt-Integration und Code-Review-Fixes (0.1.69-dev)
Core & Architektur:
- Neues Verzeichnis addon/core/ mit router.py, trakt.py, metadata.py,
  gui.py, playstate.py, plugin_manager.py, updater.py
- Tests-Verzeichnis hinzugefügt (24 Tests, pytest + Coverage)

Trakt-Integration:
- OAuth Device Flow, Scrobbling, Watchlist, History, Calendar
- Upcoming Episodes, Weiterschauen (Continue Watching)
- Watched-Status in Episodenlisten
- _trakt_find_in_plugins() mit 5-Min-Cache

Serienstream-Suche:
- API-Ergebnisse werden immer mit Katalog-Cache ergänzt (serverseitiges 10-Treffer-Limit)
- Katalog-Cache wird beim Addon-Start im Daemon-Thread vorgewärmt
- Notification nach Cache-Load via xbmc.executebuiltin() (thread-sicher)

Bugfixes (Code-Review):
- Race Condition auf _TRAKT_WATCHED_CACHE: _TRAKT_WATCHED_CACHE_LOCK hinzugefügt
- GUI-Dialog aus Daemon-Thread: xbmcgui -> xbmc.executebuiltin()
- ValueError in Trakt-Watchlist-Routen abgesichert
- Token expires_at==0 Check korrigiert
- get_setting_bool() Kontrollfluss in gui.py bereinigt
- topstreamfilm_plugin: try-finally um xbmcvfs.File.close()

Cleanup:
- default.py.bak und refactor_router.py entfernt
- .gitignore: /tests/ Eintrag entfernt
- Type-Hints vereinheitlicht (Dict/List/Tuple -> dict/list/tuple)
2026-03-01 18:39:05 +01:00

49 lines
1.5 KiB
Python

import os
import time
import pytest
from addon.plugins.serienstream_plugin import SerienstreamPlugin
@pytest.mark.live
@pytest.mark.perf
def test_live_titel_staffel_episode_timing():
if not os.getenv("LIVE_TESTS"):
pytest.skip("LIVE_TESTS not set")
title = os.getenv("LIVE_TITLE", "Star Trek: Starfleet Academy")
season = os.getenv("LIVE_SEASON", "Staffel 1")
max_title_to_season = float(os.getenv("PERF_MAX_TITLE_TO_SEASON", "6.0"))
max_season_to_episodes = float(os.getenv("PERF_MAX_SEASON_TO_EPISODES", "5.0"))
plugin = SerienstreamPlugin()
t0 = time.perf_counter()
seasons = plugin.seasons_for(title)
t1 = time.perf_counter()
assert seasons, f"Keine Staffeln für Titel gefunden: {title}"
assert season in seasons, f"Gewünschte Staffel fehlt: {season}; vorhanden: {seasons}"
episodes = plugin.episodes_for(title, season)
t2 = time.perf_counter()
assert episodes, f"Keine Episoden für {title} / {season}"
title_to_season = t1 - t0
season_to_episodes = t2 - t1
print(
f"PERF title->seasons={title_to_season:.3f}s "
f"season->episodes={season_to_episodes:.3f}s "
f"episodes={len(episodes)}"
)
assert title_to_season <= max_title_to_season, (
f"title->seasons zu langsam: {title_to_season:.3f}s > {max_title_to_season:.3f}s"
)
assert season_to_episodes <= max_season_to_episodes, (
f"season->episodes zu langsam: {season_to_episodes:.3f}s > {max_season_to_episodes:.3f}s"
)