Fixed show name formatting issues.

Added tests for XEM scene numbering.
This commit is contained in:
echel0n 2014-04-26 13:12:58 -07:00
parent df42e0e9f9
commit 4f049f4e7e
6 changed files with 72 additions and 68 deletions

View File

@ -1742,7 +1742,7 @@ class TVEpisode(object):
Returns: A string representing the episode's name and season/ep numbers
"""
return self._format_pattern('%SN - %SSx%0SE - %EN')
return self._format_pattern('%SN - %XMSx%0XME - %EN')
def _ep_name(self):
"""
@ -1843,10 +1843,10 @@ class TVEpisode(object):
'%0S': '%02d' % self.season,
'%E': str(self.episode),
'%0E': '%02d' % self.episode,
'%XS': str(self.scene_season),
'%0XS': '%02d' % self.scene_season,
'%XE': str(self.scene_episode),
'%0XE': '%02d' % self.scene_episode,
'%XMS': str(self.scene_season),
'%0XMS': '%02d' % self.scene_season,
'%XME': str(self.scene_episode),
'%0XME': '%02d' % self.scene_episode,
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': str(self.airdate).replace('-', ' '),

View File

@ -109,10 +109,6 @@ simple_test_cases = {
'2010-11-23 - Ep Name': parser.ParseResult(None, extra_info = 'Ep Name', air_date = datetime.date(2010,11,23)),
'Show.Name.2010.11.23.WEB-DL': parser.ParseResult(None, 'Show Name', None, [], 'WEB-DL', None, datetime.date(2010,11,23)),
},
'scene_sports_date_format': {
'UFC 165 Jones vs Gustafsson 21st Sept 2013 HDTV x264-Sir Paul': parser.ParseResult(None, 'UFC', None, [], 'HDTV x264-Sir Paul', 'Group', datetime.date(2013,11,23))
}
}
combination_test_cases = [
@ -335,10 +331,6 @@ class BasicTests(unittest.TestCase):
# np = parser.NameParser()
# self._test_names(np, 'scene_date_format', lambda x: x + '.avi')
def test_scene_sports_date_format_file_names(self):
np = parser.NameParser()
self._test_names(np, 'scene_sports_date_format', lambda x: x + '.avi')
def test_combination_names(self):
pass

View File

@ -69,7 +69,7 @@ def test_generator(tvdbdid, show_name, curData, forceSearch):
def test(self):
global searchItems
searchItems = curData["i"]
show = TVShow(tvdbdid)
show = TVShow(1, tvdbdid)
show.name = show_name
show.quality = curData["q"]
show.saveToDB()

View File

@ -1,49 +0,0 @@
# coding=UTF-8
# Author: Dennis Lutter <lad1337@gmail.com>
# URL: http://code.google.com/p/sickbeard/
#
# This file is part of Sick Beard.
#
# Sick Beard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sick Beard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
from __future__ import with_statement
import re
import unittest
import sys, os.path
sys.path.append(os.path.abspath('..'))
sys.path.append(os.path.abspath('../lib'))
import sickbeard
from lib.feedparser import feedparser
class APICheck(unittest.TestCase):
resultFilters = ["sub(pack|s|bed)", "swesub(bed)?",
"(dir|sample|sub|nfo)fix", "sample", "(dvd)?extras",
"dub(bed)?"]
search_term = u'Watershed.-.Exploring.a.New.Water.Ethic.for.the.New.West.1080i.HDTV.DD2.0.H.264-TrollHD'
#search_term = re.escape(search_term)
filters = [re.compile('(^|[\W_]|[\s_])%s($|[\W_]|[\s_])' % filter.strip(), re.I) for filter in resultFilters + sickbeard.IGNORE_WORDS.split(',')]
for regfilter in filters:
if regfilter.search(search_term):
print 'bad'
print 'good'
if __name__ == "__main__":
unittest.main()

View File

@ -30,11 +30,11 @@ class TVShowTests(test.SickbeardTestDBCase):
sickbeard.showList = []
def test_init_tvdbid(self):
show = TVShow(0001, "en")
show = TVShow(1, 0001, "en")
self.assertEqual(show.tvdbid, 0001)
def test_change_tvdbid(self):
show = TVShow(0001, "en")
show = TVShow(1, 0001, "en")
show.name = "show name"
show.tvrname = "show name"
show.network = "cbs"
@ -54,7 +54,7 @@ class TVShowTests(test.SickbeardTestDBCase):
self.assertEqual(show.tvdbid, 0002)
def test_set_name(self):
show = TVShow(0001, "en")
show = TVShow(1, 0001, "en")
show.name = "newName"
show.saveToDB()
show.loadFromDB(skipNFO=True)
@ -68,7 +68,7 @@ class TVEpisodeTests(test.SickbeardTestDBCase):
sickbeard.showList = []
def test_init_empty_db(self):
show = TVShow(0001, "en")
show = TVShow(1, 0001, "en")
ep = TVEpisode(show, 1, 1)
ep.name = "asdasdasdajkaj"
ep.saveToDB()
@ -83,7 +83,7 @@ class TVTests(test.SickbeardTestDBCase):
sickbeard.showList = []
def test_getEpisode(self):
show = TVShow(0001, "en")
show = TVShow(1, 0001, "en")
show.name = "show name"
show.tvrname = "show name"
show.network = "cbs"

61
tests/xem_tests.py Normal file
View File

@ -0,0 +1,61 @@
# coding=UTF-8
# Author: Dennis Lutter <lad1337@gmail.com>
# URL: http://code.google.com/p/sickbeard/
#
# This file is part of Sick Beard.
#
# Sick Beard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sick Beard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
from __future__ import with_statement
import unittest
import sys, os.path
sys.path.append(os.path.abspath('..'))
sys.path.append(os.path.abspath('../lib'))
import test_lib as test
import sickbeard
from sickbeard.tv import TVShow, TVEpisode
class XEMBasicTests(test.SickbeardTestDBCase):
def loadFromDB(self):
"""
Populates the showList with shows from the database
"""
myDB = test.db.DBConnection()
sqlResults = myDB.select("SELECT * FROM tv_shows")
for sqlShow in sqlResults:
try:
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
sickbeard.showList.append(curShow)
except Exception, e:
print "There was an error creating the show"
def test_formating(self):
self.loadFromDB()
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 111051)
ep = show.getEpisode(2014, 34)
print(
u'Searching "%s" for "%s" as "%s"' % (show.name, ep.prettyName(), ep.scene_prettyName()))
if __name__ == "__main__":
print "=================="
print "STARTING - XEM Scene Numbering TESTS"
print "=================="
print "######################################################################"
suite = unittest.TestLoader().loadTestsFromTestCase(XEMBasicTests)