Added some unit tests and fixed the mythtv ones
This commit is contained in:
@@ -19,7 +19,7 @@ class EncodeData:
|
|||||||
show - The name of the show
|
show - The name of the show
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, inputfile='', show=None, outputfile=''):
|
def __init__(self, show=None, inputfile='', outputfile=''):
|
||||||
self.inputfile = inputfile
|
self.inputfile = inputfile
|
||||||
self.show = show
|
self.show = show
|
||||||
self.outputfile = outputfile
|
self.outputfile = outputfile
|
||||||
|
|||||||
@@ -5,3 +5,22 @@ Created on Fri Jul 5 14:12:26 2013
|
|||||||
@author: shanef
|
@author: shanef
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, parentdir)
|
||||||
|
from libfilemanager import EncodeData
|
||||||
|
|
||||||
|
class libfilemanagertest(unittest.TestCase):
|
||||||
|
def test_EncodeDataPrint(self):
|
||||||
|
showname = "test show"
|
||||||
|
inputname = "test input"
|
||||||
|
outputname = "test output"
|
||||||
|
data = EncodeData(showname, inputname, outputname)
|
||||||
|
result = data.__str__()
|
||||||
|
expected = "Show: {0}\nInput: {1}\nOutput: " \
|
||||||
|
"{2}\n".format(showname, inputname, outputname)
|
||||||
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(libfilemanagertest)
|
||||||
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
@@ -7,45 +7,47 @@ Created on Fri Jul 5 14:12:53 2013
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from minimock import Mock
|
from minimock import Mock
|
||||||
import os,sys
|
import os
|
||||||
|
import sys
|
||||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.insert(0,parentdir)
|
sys.path.insert(0, parentdir)
|
||||||
import libmythtv
|
import libmythtv
|
||||||
|
|
||||||
|
|
||||||
class MythTVTest(unittest.TestCase):
|
class MythTVTest(unittest.TestCase):
|
||||||
def test_FixEpisodeNameNoPrefix(self):
|
def test_FixEpisodeNameNoPrefix(self):
|
||||||
settings = Mock('libsettings.Settings')
|
settings = Mock('libsettings.Settings')
|
||||||
settings.GetShowMythTVEpisodePrefix.mock_returns = ""
|
settings.getshowmythtvepisodeprefix.mock_returns = ""
|
||||||
mythtv = libmythtv.MythTV(settings)
|
mythtv = libmythtv.MythTV(settings)
|
||||||
result = mythtv.FixMythTVEpisodeName("Show", "episode")
|
result = mythtv.fixmythtvepisodename("Show", "episode")
|
||||||
self.assertEqual(result, "episode")
|
self.assertEqual(result, "episode")
|
||||||
|
|
||||||
def test_FixEpisodeNameNonMatchingPrefix(self):
|
def test_FixEpisodeNameNonMatchingPrefix(self):
|
||||||
settings = Mock('libsettings.Settings')
|
settings = Mock('libsettings.Settings')
|
||||||
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "BloohBlah" ]
|
settings.getshowmythtvepisodeprefix.mock_returns = [ "BloohBlah" ]
|
||||||
mythtv = libmythtv.MythTV(settings)
|
mythtv = libmythtv.MythTV(settings)
|
||||||
result = mythtv.FixMythTVEpisodeName("Show", "episode")
|
result = mythtv.fixmythtvepisodename("Show", "episode")
|
||||||
self.assertEqual(result, "episode")
|
self.assertEqual(result, "episode")
|
||||||
|
|
||||||
def test_FixEpisodeNameMatchingPrefix(self):
|
def test_FixEpisodeNameMatchingPrefix(self):
|
||||||
settings = Mock('libsettings.Settings')
|
settings = Mock('libsettings.Settings')
|
||||||
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match " ]
|
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match " ]
|
||||||
mythtv = libmythtv.MythTV(settings)
|
mythtv = libmythtv.MythTV(settings)
|
||||||
result = mythtv.FixMythTVEpisodeName("Show", "Match episode")
|
result = mythtv.fixmythtvepisodename("Show", "Match episode")
|
||||||
self.assertEqual(result, "episode")
|
self.assertEqual(result, "episode")
|
||||||
|
|
||||||
def test_FixEpisodeNameMatchingFirstPrefix(self):
|
def test_FixEpisodeNameMatchingFirstPrefix(self):
|
||||||
settings = Mock('libsettings.Settings')
|
settings = Mock('libsettings.Settings')
|
||||||
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match and ", "Match the " ]
|
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match and ", "Match the " ]
|
||||||
mythtv = libmythtv.MythTV(settings)
|
mythtv = libmythtv.MythTV(settings)
|
||||||
result = mythtv.FixMythTVEpisodeName("Show", "Match and episode")
|
result = mythtv.fixmythtvepisodename("Show", "Match and episode")
|
||||||
self.assertEqual(result, "episode")
|
self.assertEqual(result, "episode")
|
||||||
|
|
||||||
def test_FixEpisodeNameMatchingSecondPrefix(self):
|
def test_FixEpisodeNameMatchingSecondPrefix(self):
|
||||||
settings = Mock('libsettings.Settings')
|
settings = Mock('libsettings.Settings')
|
||||||
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match and ", "Match the " ]
|
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match and ", "Match the " ]
|
||||||
mythtv = libmythtv.MythTV(settings)
|
mythtv = libmythtv.MythTV(settings)
|
||||||
result = mythtv.FixMythTVEpisodeName("Show", "Match the episode")
|
result = mythtv.fixmythtvepisodename("Show", "Match the episode")
|
||||||
self.assertEqual(result, "episode")
|
self.assertEqual(result, "episode")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user