Ignore ? in filenames since they are illegal
This commit is contained in:
45
tests/TVEncodertest.py
Normal file
45
tests/TVEncodertest.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sat Jul 13 20:37:47 2013
|
||||
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parentdir)
|
||||
import TVEncoder
|
||||
|
||||
|
||||
class TVEncoderTest(unittest.TestCase):
|
||||
def test_processarguments_encodereadonly(self):
|
||||
args = []
|
||||
args.append(('-e', ''))
|
||||
args.append(('-l', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertTrue(result.readonly)
|
||||
|
||||
def test_processarguments_encodereadonlyreverse(self):
|
||||
args = []
|
||||
args.append(('-l', ''))
|
||||
args.append(('-e', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertTrue(result.readonly)
|
||||
|
||||
def test_processarguments_encode(self):
|
||||
args = []
|
||||
args.append(('-e', ''))
|
||||
result = TVEncoder.processarguments(args)
|
||||
|
||||
self.assertTrue(result.doencode)
|
||||
self.assertFalse(result.readonly)
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TVEncoderTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
38
tests/libtvdatasourcetest.py
Normal file
38
tests/libtvdatasourcetest.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Thu Jul 18 23:13:15 2013
|
||||
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from minimock import Mock
|
||||
import os
|
||||
import sys
|
||||
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parentdir)
|
||||
import libtvdatasource
|
||||
|
||||
|
||||
class tvdatasourceTest(unittest.TestCase):
|
||||
def test_GetOutputFilenameNoIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "test name", "")
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def test_GetOutputFilenameOneIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "test name?", "?")
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def test_GetOutputFilenameTwoIllegals(self):
|
||||
result = self._dooutputfilenametest("S01", "E02", "tes>t name?", ["?", ">"])
|
||||
self.assertEqual(result, "S01E02 - test name - SD TV_.mpg")
|
||||
|
||||
def _dooutputfilenametest(self, season, episode, name, illegals):
|
||||
settings = Mock('libsettings.Settings')
|
||||
settings.illegalcharacters.mock_returns = illegals
|
||||
tvdatasource = libtvdatasource.TVData(settings)
|
||||
return tvdatasource.getoutputfilename(season, episode, name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(tvdatasourceTest)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
Reference in New Issue
Block a user