mirror of
https://github.com/Hellowlol/bw_plex.git
synced 2026-05-13 01:38:23 -05:00
add test_process
This commit is contained in:
+2
-2
@@ -116,7 +116,7 @@ def video_frame_by_frame(path, offset=0, frame_range=None, step=1):
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
|
||||
def calc_success(rectangles, img_height, img_width, success=0.9):
|
||||
def calc_success(rectangles, img_height, img_width, success=0.9): # pragma: no cover
|
||||
"""Helper to check the n percentage of the image is covered in text."""
|
||||
t = sum([i[2] * i[3] for i in rectangles if i])
|
||||
p = 100 * float(t) / float(img_height * img_width)
|
||||
@@ -311,7 +311,7 @@ def find_credits(path, offset=0, fps=None, duration=None, check=7, step=1, frame
|
||||
@click.option('-d', '--debug', is_flag=True, default=False)
|
||||
@click.option('-p', '--profile', is_flag=True, default=False)
|
||||
@click.option('-o', '--offset', default=0, type=int)
|
||||
def cmd(path, c, debug, profile, offset):
|
||||
def cmd(path, c, debug, profile, offset): # pragma: no cover
|
||||
|
||||
if os.path.isfile(path):
|
||||
files = [path]
|
||||
|
||||
+6
-7
@@ -421,7 +421,7 @@ def manually_correct_theme(name, url, type, rk, just_theme):
|
||||
@click.option('-s', '--show', default=None)
|
||||
@click.option('-t', '--type', default='youtube')
|
||||
@click.option('-f', '--force', default=False, is_flag=True)
|
||||
def find_theme(show, type, force):
|
||||
def find_theme(show, type, force): # pragma: no cover
|
||||
"""Iterate over all your shows and downloads the first match for
|
||||
showname theme song on youtube.
|
||||
|
||||
@@ -437,7 +437,8 @@ def find_theme(show, type, force):
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
# FIX ME
|
||||
# Fuck it, just remove the entire func.
|
||||
# FIX ME
|
||||
if show is not None:
|
||||
if type == 'youtube':
|
||||
search_for_theme_youtube(show, rk=1, save_path=TEMP_THEMES)
|
||||
@@ -627,7 +628,7 @@ def client_jump_to(offset=None, sessionkey=None):
|
||||
# time.sleep(0.2)
|
||||
# client.play()
|
||||
JUMP_LIST.remove(sessionkey)
|
||||
#time.sleep(1)
|
||||
# time.sleep(1)
|
||||
|
||||
return
|
||||
|
||||
@@ -672,8 +673,6 @@ def task(item, sessionkey):
|
||||
def check(data):
|
||||
global JUMP_LIST
|
||||
|
||||
print(data)
|
||||
|
||||
if data.get('type') == 'playing' and data.get(
|
||||
'PlaySessionStateNotification'):
|
||||
|
||||
@@ -752,8 +751,8 @@ def check(data):
|
||||
@cli.command()
|
||||
@click.argument('-f', type=click.Path(exists=True))
|
||||
def match(f):
|
||||
"""Manual match for a file. This is usefull for testing the a finds the correct end time."""
|
||||
# assert f in H.names
|
||||
"""Manual match for a file. This is useful for testing we finds the correct start and
|
||||
end time."""
|
||||
global HT
|
||||
HT = get_hashtable()
|
||||
x = get_offset_end(f, HT)
|
||||
|
||||
+18
-10
@@ -65,17 +65,7 @@ def HT():
|
||||
return misc.get_hashtable()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def media(mocker):
|
||||
media = mocker.Mock(spec=Show)
|
||||
media.TYPE = 'show'
|
||||
media.name = 'dexter'
|
||||
media.ratingKey = 1337
|
||||
media.theme = ''
|
||||
media._server = ''
|
||||
media.title = 'dexter'
|
||||
|
||||
return media
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -105,3 +95,21 @@ def episode(mocker):
|
||||
ep._prettyfilename = _prettyfilename
|
||||
|
||||
return ep
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def media(mocker, episode):
|
||||
media = mocker.Mock(spec=Show)
|
||||
media.TYPE = 'show'
|
||||
media.name = 'dexter'
|
||||
media.ratingKey = 1337
|
||||
media.theme = ''
|
||||
media._server = ''
|
||||
media.title = 'dexter'
|
||||
|
||||
def _episodes():
|
||||
return [episode]
|
||||
|
||||
media.episodes = _episodes
|
||||
|
||||
return media
|
||||
|
||||
+26
-4
@@ -82,8 +82,6 @@ def _test_process_to_db(episode, intro_file, cli_runner, tmpdir, monkeypatch, HT
|
||||
|
||||
plex.task(1337, 1)
|
||||
|
||||
#plex.process_to_db(episode, vid=str(intro_file), start=10, end=20, ffmpeg_end=99, recap=False)
|
||||
|
||||
with plex.session_scope() as se:
|
||||
assert se.query(plex.Preprocessed).filter_by(ratingKey=episode.ratingKey).one()
|
||||
|
||||
@@ -99,11 +97,35 @@ def _test_process_to_db(episode, intro_file, cli_runner, tmpdir, monkeypatch, HT
|
||||
assert json.load(f)
|
||||
|
||||
|
||||
def test_process(cli_runner, monkeypatch, episode, media, HT, intro_file, mocker):
|
||||
# Let the mock begin..
|
||||
#monkeypatch(plex, 'find_all_shows', lambda k: list(show))
|
||||
def j(a=None):
|
||||
return [media]
|
||||
def t(a=None):
|
||||
return [episode]
|
||||
mocker.patch.object(plex, 'find_all_shows', side_effect=[[media], [episode]])
|
||||
mocker.patch('click.prompt', side_effect=['0', '0'])
|
||||
|
||||
def fetchItem(i):
|
||||
return episode
|
||||
|
||||
m = mocker.Mock()
|
||||
m.fetchItem = fetchItem
|
||||
|
||||
def zomg(*args, **kwargs):
|
||||
pass
|
||||
|
||||
monkeypatch.setitem(plex.CONFIG, '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'])
|
||||
print(res.output)
|
||||
print('ass')
|
||||
|
||||
def test_process():
|
||||
pass
|
||||
|
||||
|
||||
def test_add_theme_to_hashtable(cli_runner, monkeypatch, HT):
|
||||
|
||||
Reference in New Issue
Block a user