2014-04-26 16:12:58 -04:00
|
|
|
# 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
|
2014-04-27 18:51:52 -04:00
|
|
|
import datetime
|
2014-04-26 16:12:58 -04:00
|
|
|
|
|
|
|
sys.path.append(os.path.abspath('..'))
|
|
|
|
sys.path.append(os.path.abspath('../lib'))
|
|
|
|
|
|
|
|
import test_lib as test
|
|
|
|
import sickbeard
|
2014-05-01 07:36:16 -04:00
|
|
|
from sickbeard.helpers import sanitizeSceneName, custom_strftime
|
2014-04-27 06:31:54 -04:00
|
|
|
from sickbeard.tv import TVShow
|
2014-04-26 16:12:58 -04:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2014-05-01 07:36:16 -04:00
|
|
|
def test_formating(self):
|
2014-04-26 16:12:58 -04:00
|
|
|
self.loadFromDB()
|
2014-05-01 07:36:16 -04:00
|
|
|
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 75978)
|
|
|
|
ep = show.getEpisode(7, 6)
|
|
|
|
ep.airdate = datetime.datetime.now()
|
2014-04-28 05:15:29 -04:00
|
|
|
|
2014-05-01 07:36:16 -04:00
|
|
|
print format(ep.episode, '02d')
|
|
|
|
print format(ep.scene_episode, '02d')
|
|
|
|
|
|
|
|
search_string = {'Episode':[]}
|
|
|
|
episode = ep.airdate
|
|
|
|
str(episode).replace('-', '|')
|
|
|
|
ep_string = sanitizeSceneName(show.name) + ' ' + \
|
|
|
|
str(episode).replace('-', '|') + '|' + \
|
|
|
|
sickbeard.helpers.custom_strftime('%b', episode)
|
|
|
|
|
|
|
|
search_string['Episode'].append(ep_string)
|
|
|
|
|
|
|
|
scene_ep_string = sanitizeSceneName(show.name) + ' ' + \
|
|
|
|
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep.scene_season,
|
|
|
|
'episodenumber': ep.scene_episode} + '|' + \
|
|
|
|
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep.scene_season,
|
|
|
|
'episodenumber': ep.scene_episode} + '|' + \
|
|
|
|
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep.scene_season,
|
|
|
|
'episodenumber': ep.scene_episode} + ' %s category:tv' % ''
|
|
|
|
|
|
|
|
scene_season_string = show.name + ' S%02d' % int(ep.scene_season) + ' -S%02d' % int(ep.scene_season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE
|
|
|
|
|
|
|
|
|
|
|
|
print(
|
|
|
|
u'Searching "%s" for "%s" as "%s"' % (show.name, ep.prettyName(), ep.scene_prettyName()))
|
|
|
|
|
|
|
|
print('Scene episode search strings: %s' % (scene_ep_string))
|
|
|
|
|
|
|
|
print('Scene season search strings: %s' % (scene_season_string))
|
2014-04-30 18:07:18 -04:00
|
|
|
|
2014-04-26 16:12:58 -04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
print "=================="
|
|
|
|
print "STARTING - XEM Scene Numbering TESTS"
|
|
|
|
print "=================="
|
|
|
|
print "######################################################################"
|
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(XEMBasicTests)
|