Added some unit tests and fixed the mythtv ones

This commit is contained in:
2013-07-13 15:50:47 +10:00
parent 3c2d87e6de
commit b9df25ddf0
3 changed files with 35 additions and 14 deletions

View File

@@ -19,7 +19,7 @@ class EncodeData:
show - The name of the show
"""
def __init__(self, inputfile='', show=None, outputfile=''):
def __init__(self, show=None, inputfile='', outputfile=''):
self.inputfile = inputfile
self.show = show
self.outputfile = outputfile

View File

@@ -5,3 +5,22 @@ Created on Fri Jul 5 14:12:26 2013
@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)

View File

@@ -7,45 +7,47 @@ Created on Fri Jul 5 14:12:53 2013
import unittest
from minimock import Mock
import os,sys
import os
import sys
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, parentdir)
import libmythtv
class MythTVTest(unittest.TestCase):
def test_FixEpisodeNameNoPrefix(self):
settings = Mock('libsettings.Settings')
settings.GetShowMythTVEpisodePrefix.mock_returns = ""
settings.getshowmythtvepisodeprefix.mock_returns = ""
mythtv = libmythtv.MythTV(settings)
result = mythtv.FixMythTVEpisodeName("Show", "episode")
result = mythtv.fixmythtvepisodename("Show", "episode")
self.assertEqual(result, "episode")
def test_FixEpisodeNameNonMatchingPrefix(self):
settings = Mock('libsettings.Settings')
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "BloohBlah" ]
settings.getshowmythtvepisodeprefix.mock_returns = [ "BloohBlah" ]
mythtv = libmythtv.MythTV(settings)
result = mythtv.FixMythTVEpisodeName("Show", "episode")
result = mythtv.fixmythtvepisodename("Show", "episode")
self.assertEqual(result, "episode")
def test_FixEpisodeNameMatchingPrefix(self):
settings = Mock('libsettings.Settings')
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match " ]
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match " ]
mythtv = libmythtv.MythTV(settings)
result = mythtv.FixMythTVEpisodeName("Show", "Match episode")
result = mythtv.fixmythtvepisodename("Show", "Match episode")
self.assertEqual(result, "episode")
def test_FixEpisodeNameMatchingFirstPrefix(self):
settings = Mock('libsettings.Settings')
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match and ", "Match the " ]
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match and ", "Match the " ]
mythtv = libmythtv.MythTV(settings)
result = mythtv.FixMythTVEpisodeName("Show", "Match and episode")
result = mythtv.fixmythtvepisodename("Show", "Match and episode")
self.assertEqual(result, "episode")
def test_FixEpisodeNameMatchingSecondPrefix(self):
settings = Mock('libsettings.Settings')
settings.GetShowMythTVEpisodePrefix.mock_returns = [ "Match and ", "Match the " ]
settings.getshowmythtvepisodeprefix.mock_returns = [ "Match and ", "Match the " ]
mythtv = libmythtv.MythTV(settings)
result = mythtv.FixMythTVEpisodeName("Show", "Match the episode")
result = mythtv.fixmythtvepisodename("Show", "Match the episode")
self.assertEqual(result, "episode")
if __name__ == '__main__':