Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
test: wait until plugin is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 18, 2023
1 parent c44d595 commit 7a86a23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
SERVER_TOKEN = plexapi.CONFIG.get("auth.server_token")


def wait_for_file(file_path, timeout=300):
# type: (str, int) -> None
found = False
count = 0
while not found and count < timeout: # plugin takes a little while to start on macOS
count += 1
if os.path.isfile(file_path):
found = True
else:
time.sleep(1)
assert found, "After {} seconds, {} file not found".format(timeout, file_path)


def wait_for_themes(movies):
# ensure library is not refreshing
while movies.refreshing:
Expand Down Expand Up @@ -91,6 +104,8 @@ def plugin_log_file():
# the primary plugin log file
plugin_log_file = os.path.join(os.environ['PLEX_PLUGIN_LOG_PATH'], "{}.log".format(constants.plugin_identifier))

wait_for_file(file_path=plugin_log_file, timeout=300)

yield plugin_log_file


Expand Down
12 changes: 1 addition & 11 deletions tests/functional/test_plex_plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# standard imports
import os
import time


def _check_themes(movies):
Expand All @@ -17,16 +16,7 @@ def test_plugin_logs(plugin_logs):


def test_plugin_log_file(plugin_log_file):
found = False
count = 0
max_count = 120
while not found and count < max_count: # plugin takes a little while to start on macOS
count += 1
if os.path.isfile(plugin_log_file):
found = True
else:
time.sleep(1)
assert found, "After {} seconds, plugin log file not found: {}".format(max_count, plugin_log_file)
assert os.path.isfile(plugin_log_file), "Plugin log file not found"


def test_plugin_log_file_exceptions(plugin_log_file):
Expand Down

0 comments on commit 7a86a23

Please sign in to comment.