mirror of
https://github.com/Hellowlol/bw_plex.git
synced 2026-05-07 06:51:14 -05:00
Try to fix tests.
This commit is contained in:
@@ -15,6 +15,7 @@ FP_HASHES = os.path.join(DEFAULT_FOLDER, 'hashes.pklz')
|
||||
LOG_FILE = os.path.join(DEFAULT_FOLDER, 'log.txt')
|
||||
LOG = logging.getLogger('bw_plex')
|
||||
INI_FILE = os.path.join(DEFAULT_FOLDER, 'config.ini')
|
||||
DB_PATH = os.path.join(DEFAULT_FOLDER, 'media.db')
|
||||
|
||||
|
||||
makedirs(DEFAULT_FOLDER, exist_ok=True)
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ password = string(default='')
|
||||
# This could be season, show or ep.
|
||||
#ignore_intro_ratingkeys = list(default=list())
|
||||
#ignore_outro_ratingkeys = list(default=list())
|
||||
check_credits = boolean(default=False
|
||||
check_credits = boolean(default=False)
|
||||
check_credits_action = string(default='')
|
||||
check_credits_start_next_ep = boolean(default=True)
|
||||
check_credits_sec = integer(default=120)
|
||||
|
||||
+1
-3
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
|
||||
from sqlalchemy import create_engine, Boolean, Column, DateTime, Integer, String
|
||||
@@ -6,9 +5,8 @@ from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
from . import DEFAULT_FOLDER
|
||||
from . import DB_PATH
|
||||
|
||||
DB_PATH = os.path.join(DEFAULT_FOLDER, 'media.db')
|
||||
|
||||
eng = create_engine('sqlite:///' + DB_PATH)
|
||||
session_factory = sessionmaker(bind=eng)
|
||||
|
||||
+1
-1
@@ -536,7 +536,7 @@ def download_theme(media, ht, theme_source=None, url=None):
|
||||
pms = media._server
|
||||
|
||||
if theme_source is None:
|
||||
theme_source = CONFIG['general'].get('theme_source', 'all')
|
||||
theme_source = CONFIG['tv'].get('theme_source', 'all')
|
||||
|
||||
if theme_source == 'youtube':
|
||||
theme = search_for_theme_youtube(name, rk, THEMES, url=url)
|
||||
|
||||
+5
-3
@@ -730,7 +730,7 @@ def task(item, sessionkey):
|
||||
"""
|
||||
global HT
|
||||
media = PMS.fetchItem(int(item))
|
||||
# LOG.debug('Found %s', media._prettyfilename())
|
||||
LOG.debug('Found %s', media._prettyfilename())
|
||||
if media.TYPE not in ('episode', 'show', 'movie'):
|
||||
return
|
||||
|
||||
@@ -859,7 +859,8 @@ def check(data):
|
||||
if ratingkey not in IN_PROG:
|
||||
IN_PROG.append(ratingkey)
|
||||
LOG.debug('Failed to find ratingkey %s in the db', ratingkey)
|
||||
POOL.apply_async(task, args=(ratingkey, sessionkey))
|
||||
ret = POOL.apply_async(task, args=(ratingkey, sessionkey))
|
||||
return ret
|
||||
|
||||
elif data.get('type') == 'timeline':
|
||||
timeline = data.get('TimelineEntry')[0]
|
||||
@@ -885,7 +886,8 @@ def check(data):
|
||||
if ratingkey not in IN_PROG:
|
||||
IN_PROG.append(ratingkey)
|
||||
ep = PMS.fetchItem(int(ratingkey))
|
||||
POOL.apply_async(process_to_db, args=(ep,))
|
||||
ret = POOL.apply_async(process_to_db, args=(ep,))
|
||||
return ret
|
||||
|
||||
elif (metadata_type in (1, 4) and state == 9 and
|
||||
metadata_state == 'deleted'):
|
||||
|
||||
+3
-2
@@ -6,7 +6,7 @@ from datetime import datetime as DT
|
||||
|
||||
|
||||
from plexapi.video import Episode, Show
|
||||
from plexapi.compat import makedirs
|
||||
# from plexapi.compat import makedirs
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
import pytest
|
||||
|
||||
@@ -15,7 +15,6 @@ fp = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'bw_plex')
|
||||
# I dont like it..
|
||||
sys.path.insert(1, fp)
|
||||
|
||||
|
||||
import bw_plex
|
||||
|
||||
old_def = bw_plex.DEFAULT_FOLDER
|
||||
@@ -38,7 +37,9 @@ bw_plex.TEMP_THEMES = os.path.join(bw_plex.DEFAULT_FOLDER, 'temp_themes')
|
||||
bw_plex.FP_HASHES = os.path.join(bw_plex.DEFAULT_FOLDER, 'hashes.pklz')
|
||||
bw_plex.LOG_FILE = os.path.join(bw_plex.DEFAULT_FOLDER, 'log.txt')
|
||||
bw_plex.INI_FILE = os.path.join(bw_plex.DEFAULT_FOLDER, 'config.ini')
|
||||
bw_plex.DB_PATH = os.path.join(bw_plex.DEFAULT_FOLDER, 'media.db')
|
||||
|
||||
# Do not remove these imports..
|
||||
import bw_plex.plex as plex
|
||||
import bw_plex.misc as misc
|
||||
import bw_plex.credits as credits
|
||||
|
||||
+9
-6
@@ -26,10 +26,12 @@ def test_check(episode, intro_file, cli_runner, tmpdir, monkeypatch, HT, mocker)
|
||||
def zomg(*args, **kwargs):
|
||||
pass
|
||||
|
||||
monkeypatch.setitem(plex.CONFIG, 'theme_source', 'tvtunes')
|
||||
monkeypatch.setattr(plex, 'check_file_access', lambda k: intro_file)
|
||||
monkeypatch.setitem(plex.CONFIG['tv'], 'theme_source', 'tvtunes')
|
||||
monkeypatch.setattr(plex, 'HT', HT)
|
||||
monkeypatch.setattr(plex, 'PMS', m)
|
||||
monkeypatch.setitem(plex.CONFIG['tv'], 'check_credits', True)
|
||||
monkeypatch.setattr(plex, 'check_file_access', lambda k: intro_file)
|
||||
|
||||
monkeypatch.setattr(plex, 'find_next', lambda k: None)
|
||||
monkeypatch.setattr(plex, 'client_action', zomg)
|
||||
|
||||
@@ -47,7 +49,7 @@ def test_check(episode, intro_file, cli_runner, tmpdir, monkeypatch, HT, mocker)
|
||||
}
|
||||
|
||||
# This should add the shit to the db. Lets check it.
|
||||
plex.check(data)
|
||||
r = plex.check(data).get()
|
||||
plex.POOL.close()
|
||||
plex.POOL.join()
|
||||
|
||||
@@ -74,7 +76,7 @@ def _test_process_to_db(episode, intro_file, cli_runner, tmpdir, monkeypatch, HT
|
||||
m = mocker.Mock()
|
||||
m.fetchItem = fetchItem
|
||||
|
||||
monkeypatch.setitem(plex.CONFIG, 'theme_source', 'tvtunes')
|
||||
monkeypatch.setitem(plex.CONFIG['tv'], 'theme_source', 'tvtunes')
|
||||
monkeypatch.setattr(plex, 'check_file_access', lambda k: intro_file)
|
||||
monkeypatch.setattr(plex, 'HT', HT)
|
||||
monkeypatch.setattr(plex, 'PMS', m)
|
||||
@@ -110,10 +112,11 @@ def test_process(cli_runner, monkeypatch, episode, media, HT, intro_file, mocker
|
||||
def zomg(*args, **kwargs):
|
||||
pass
|
||||
|
||||
monkeypatch.setitem(plex.CONFIG, 'theme_source', 'tvtunes')
|
||||
monkeypatch.setattr(plex, 'PMS', m)
|
||||
monkeypatch.setitem(plex.CONFIG['tv'], 'theme_source', 'tvtunes')
|
||||
monkeypatch.setattr(plex, 'check_file_access', lambda k: intro_file)
|
||||
monkeypatch.setattr(plex, 'HT', HT)
|
||||
monkeypatch.setattr(plex, 'PMS', m)
|
||||
|
||||
monkeypatch.setattr(plex, 'find_next', lambda k: None)
|
||||
|
||||
res = cli_runner.invoke(plex.process, ['-n', 'dexter', '-s', '1', '-t', '2', '-sd'])
|
||||
|
||||
Reference in New Issue
Block a user