mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-13 06:42:16 +00:00
Added further tests, PEP8 cleanup
This commit is contained in:
@@ -23,13 +23,20 @@ class testTvOrganise(unittest.TestCase):
|
|||||||
|
|
||||||
def testConfigSettings(self):
|
def testConfigSettings(self):
|
||||||
"""
|
"""
|
||||||
Using a predefined dict, save then load the config and validate
|
Using a predefined dict, save then load the config and validate
|
||||||
the contents
|
the contents
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def testParseFilenames(self):
|
||||||
|
files = ['/media/out/Heroes - [01x05] - Llamaggeddon.avi']
|
||||||
|
|
||||||
|
res = self.tvo.parse_filenames(files)
|
||||||
|
self.assertEqual(res[0]['showname'], 'Heroes')
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.tvo = tvorganise.TvOrganiser()
|
self.tvo = tvorganise.TvOrganiser()
|
||||||
|
self.tvo._config = tvorganise.config.Config('tvorganise.cfg')
|
||||||
|
|
||||||
|
|
||||||
class testFindFiles(unittest.TestCase):
|
class testFindFiles(unittest.TestCase):
|
||||||
@@ -41,14 +48,14 @@ class testFindFiles(unittest.TestCase):
|
|||||||
os.makedirs("/tmp/find-files-test/folder1")
|
os.makedirs("/tmp/find-files-test/folder1")
|
||||||
os.makedirs("/tmp/find-files-test/folder2")
|
os.makedirs("/tmp/find-files-test/folder2")
|
||||||
|
|
||||||
open('/tmp/find-files-test/folder1/file1', 'w').close()
|
open('/tmp/find-files-test/folder1/file1', 'w').close()
|
||||||
open('/tmp/find-files-test/folder1/file2', 'w').close()
|
open('/tmp/find-files-test/folder1/file2', 'w').close()
|
||||||
open('/tmp/find-files-test/folder2/file3', 'w').close()
|
open('/tmp/find-files-test/folder2/file3', 'w').close()
|
||||||
open('/tmp/find-files-test/folder2/file4', 'w').close()
|
open('/tmp/find-files-test/folder2/file4', 'w').close()
|
||||||
open('/tmp/find-files-test/folder2/file5', 'w').close()
|
open('/tmp/find-files-test/folder2/file5', 'w').close()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree("/tmp/find-files-test/")
|
shutil.rmtree("/tmp/find-files-test/")
|
||||||
|
|
||||||
def testFolderList(self):
|
def testFolderList(self):
|
||||||
self.assertEqual(len(tvorganise.find_files("/tmp/find-files-test/")),5)
|
self.assertEqual(len(tvorganise.find_files("/tmp/find-files-test/")),5)
|
||||||
@@ -69,7 +76,7 @@ def suite(suite=None):
|
|||||||
|
|
||||||
suite.addTest(unittest.makeSuite(testTvOrganise))
|
suite.addTest(unittest.makeSuite(testTvOrganise))
|
||||||
suite.addTest(unittest.makeSuite(testFindFiles))
|
suite.addTest(unittest.makeSuite(testFindFiles))
|
||||||
|
|
||||||
return suite
|
return suite
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
@@ -13,11 +13,10 @@ import sys
|
|||||||
import re
|
import re
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import shutil
|
import shutil
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
|
||||||
def same_partition(path1, path2):
|
def same_partition(path1, path2):
|
||||||
"""
|
"""
|
||||||
Checks to see if two paths are on the same device, returns a
|
Checks to see if two paths are on the same device, returns a
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
import ConfigParser
|
import ConfigParser
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def defaults():
|
def defaults():
|
||||||
"""
|
"""
|
||||||
Creates a ConfigParser instance and fills it with the default settings
|
Creates a ConfigParser instance and fills it with the default settings
|
||||||
"""
|
"""
|
||||||
|
|
||||||
config = ConfigParser.RawConfigParser()
|
config = ConfigParser.RawConfigParser()
|
||||||
|
|
||||||
config.add_section('main')
|
config.add_section('main')
|
||||||
config.set('main', 'target_path', '/media/%(showname)s/Season %(seasonnum)s/')
|
config.set('main', 'target_path', '/media/%(showname)s/Season %(seasonnum)s/')
|
||||||
|
|
||||||
config.add_section('regex')
|
config.add_section('regex')
|
||||||
config.set('regex', 'valid_in_names', "[\\w\\(\\).,\\[\\]'\\ \\-?!#:]")
|
config.set('regex', 'valid_in_names', "[\\w\\(\\).,\\[\\]'\\ \\-?!#:]")
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
class Config(dict):
|
class Config(dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user