forked from openlp/openlp
fix tests
This commit is contained in:
parent
f2537981e4
commit
bd8ddf7506
@ -378,7 +378,7 @@ def clean_filename(filename):
|
|||||||
return INVALID_FILE_CHARS.sub('_', CONTROL_CHARS.sub('', filename))
|
return INVALID_FILE_CHARS.sub('_', CONTROL_CHARS.sub('', filename))
|
||||||
|
|
||||||
|
|
||||||
def check_binary(program_path):
|
def check_binary_exists(program_path):
|
||||||
"""
|
"""
|
||||||
Function that checks whether a binary exists.
|
Function that checks whether a binary exists.
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ from shutil import which
|
|||||||
|
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
|
|
||||||
from openlp.core.common import AppLocation, Settings, translate, check_binary, is_win
|
from openlp.core.common import AppLocation, Settings, translate, check_binary_exists, is_win
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon
|
from openlp.core.lib import Plugin, StringContent, build_icon
|
||||||
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ def process_check_binary(program_path):
|
|||||||
:return: If exists or not
|
:return: If exists or not
|
||||||
"""
|
"""
|
||||||
program_type = None
|
program_type = None
|
||||||
runlog = check_binary(program_path)
|
runlog = check_binary_exists(program_path)
|
||||||
print(runlog)
|
print(runlog, type(runlog))
|
||||||
# Analyse the output to see it the program is mediainfo
|
# Analyse the output to see it the program is mediainfo
|
||||||
for line in runlog.splitlines():
|
for line in runlog.splitlines():
|
||||||
decoded_line = line.decode()
|
decoded_line = line.decode()
|
||||||
|
@ -26,7 +26,7 @@ import re
|
|||||||
from shutil import which
|
from shutil import which
|
||||||
from subprocess import check_output, CalledProcessError
|
from subprocess import check_output, CalledProcessError
|
||||||
|
|
||||||
from openlp.core.common import AppLocation, check_binary
|
from openlp.core.common import AppLocation, check_binary_exists
|
||||||
from openlp.core.common import Settings, is_win
|
from openlp.core.common import Settings, is_win
|
||||||
from openlp.core.lib import ScreenList
|
from openlp.core.lib import ScreenList
|
||||||
from .presentationcontroller import PresentationController, PresentationDocument
|
from .presentationcontroller import PresentationController, PresentationDocument
|
||||||
@ -69,7 +69,7 @@ class PdfController(PresentationController):
|
|||||||
:return: Type of the binary, 'gs' if ghostscript, 'mudraw' if mudraw, None if invalid.
|
:return: Type of the binary, 'gs' if ghostscript, 'mudraw' if mudraw, None if invalid.
|
||||||
"""
|
"""
|
||||||
program_type = None
|
program_type = None
|
||||||
runlog = check_binary(program_path)
|
runlog = check_binary_exists(program_path)
|
||||||
# Analyse the output to see it the program is mudraw, ghostscript or neither
|
# Analyse the output to see it the program is mudraw, ghostscript or neither
|
||||||
for line in runlog.splitlines():
|
for line in runlog.splitlines():
|
||||||
decoded_line = line.decode()
|
decoded_line = line.decode()
|
||||||
|
@ -64,24 +64,28 @@ class MediaPluginTest(TestCase, TestMixin):
|
|||||||
# THEN: about() should return a non-empty string
|
# THEN: about() should return a non-empty string
|
||||||
self.assertNotEquals(len(MediaPlugin.about()), 0)
|
self.assertNotEquals(len(MediaPlugin.about()), 0)
|
||||||
|
|
||||||
def process_check_binary_pass_test(self):
|
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
|
||||||
|
def process_check_binary_pass_test(self, mocked_checked_binary_exists):
|
||||||
"""
|
"""
|
||||||
Test that the Process check returns true if found
|
Test that the Process check returns true if found
|
||||||
"""
|
"""
|
||||||
# GIVEN: A media plugin instance
|
# GIVEN: A media plugin instance
|
||||||
# WHEN: function is called with the correct name
|
# WHEN: function is called with the correct name
|
||||||
result = process_check_binary("MediaInfo")
|
mocked_checked_binary_exists.return_value = str.encode('MediaInfo Command line')
|
||||||
|
result = process_check_binary('MediaInfo')
|
||||||
|
|
||||||
# THEN: The the result should be True
|
# THEN: The the result should be True
|
||||||
self.assertFalse(result, "Media info should have been found")
|
self.assertTrue(result, 'Mediainfo should have been found')
|
||||||
|
|
||||||
def process_check_binary_fail_test(self):
|
@patch('openlp.plugins.media.mediaplugin.check_binary_exists')
|
||||||
|
def process_check_binary_fail_test(self, mocked_checked_binary_exists):
|
||||||
"""
|
"""
|
||||||
Test that the Process check returns false if not found
|
Test that the Process check returns false if not found
|
||||||
"""
|
"""
|
||||||
# GIVEN: A media plugin instance
|
# GIVEN: A media plugin instance
|
||||||
# WHEN: function is called with the wrong name
|
# WHEN: function is called with the wrong name
|
||||||
|
mocked_checked_binary_exists.return_value = str.encode('MediaInfo1 Command line')
|
||||||
result = process_check_binary("MediaInfo1")
|
result = process_check_binary("MediaInfo1")
|
||||||
|
|
||||||
# THEN: The the result should be True
|
# THEN: The the result should be True
|
||||||
self.assertTrue(result, "Media info should not have been found")
|
self.assertFalse(result, "Mediainfo should not have been found")
|
||||||
|
Loading…
Reference in New Issue
Block a user