2014-03-10 05:18:05 +00:00
|
|
|
# coding=UTF-8
|
|
|
|
# Author: Dennis Lutter <lad1337@gmail.com>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# This file is part of SickGear.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is free software: you can redistribute it and/or modify
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is distributed in the hope that it will be useful,
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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
|
2014-11-12 16:43:14 +00:00
|
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-06-09 11:13:00 +00:00
|
|
|
from __future__ import print_function
|
2014-03-10 05:18:05 +00:00
|
|
|
import unittest
|
|
|
|
import test_lib as test
|
|
|
|
|
|
|
|
import sickbeard
|
|
|
|
from sickbeard.tv import TVEpisode, TVShow
|
|
|
|
|
|
|
|
class TVShowTests(test.SickbeardTestDBCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TVShowTests, self).setUp()
|
|
|
|
sickbeard.showList = []
|
|
|
|
|
2014-10-30 14:40:07 +00:00
|
|
|
def test_init_indexerid(self):
|
2015-08-11 11:51:26 +00:00
|
|
|
show = TVShow(1, 1, 'en')
|
2015-06-09 22:32:13 +00:00
|
|
|
self.assertEqual(show.indexerid, 1)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-10-30 14:40:07 +00:00
|
|
|
def test_change_indexerid(self):
|
2015-08-11 11:51:26 +00:00
|
|
|
show = TVShow(1, 1, 'en')
|
|
|
|
show.name = 'show name'
|
|
|
|
show.tvrname = 'show name'
|
|
|
|
show.network = 'cbs'
|
|
|
|
show.genre = 'crime'
|
2014-03-10 05:18:05 +00:00
|
|
|
show.runtime = 40
|
2015-08-11 11:51:26 +00:00
|
|
|
show.status = '5'
|
|
|
|
show.airs = 'monday'
|
2014-03-10 05:18:05 +00:00
|
|
|
show.startyear = 1987
|
|
|
|
|
|
|
|
show.saveToDB()
|
|
|
|
show.loadFromDB(skipNFO=True)
|
|
|
|
|
2015-06-09 22:32:13 +00:00
|
|
|
show.indexerid = 2
|
2014-03-10 05:18:05 +00:00
|
|
|
show.saveToDB()
|
|
|
|
show.loadFromDB(skipNFO=True)
|
|
|
|
|
2015-06-09 22:32:13 +00:00
|
|
|
self.assertEqual(show.indexerid, 2)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
def test_set_name(self):
|
2015-08-11 11:51:26 +00:00
|
|
|
show = TVShow(1, 1, 'en')
|
|
|
|
show.name = 'newName'
|
2014-03-10 05:18:05 +00:00
|
|
|
show.saveToDB()
|
|
|
|
show.loadFromDB(skipNFO=True)
|
2015-08-11 11:51:26 +00:00
|
|
|
self.assertEqual(show.name, 'newName')
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TVEpisodeTests(test.SickbeardTestDBCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TVEpisodeTests, self).setUp()
|
|
|
|
sickbeard.showList = []
|
|
|
|
|
|
|
|
def test_init_empty_db(self):
|
2015-08-11 11:51:26 +00:00
|
|
|
show = TVShow(1, 1, 'en')
|
2014-03-10 05:18:05 +00:00
|
|
|
ep = TVEpisode(show, 1, 1)
|
2015-08-11 11:51:26 +00:00
|
|
|
ep.name = 'asdasdasdajkaj'
|
2014-03-10 05:18:05 +00:00
|
|
|
ep.saveToDB()
|
|
|
|
ep.loadFromDB(1, 1)
|
2015-08-11 11:51:26 +00:00
|
|
|
self.assertEqual(ep.name, 'asdasdasdajkaj')
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TVTests(test.SickbeardTestDBCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TVTests, self).setUp()
|
|
|
|
sickbeard.showList = []
|
|
|
|
|
|
|
|
def test_getEpisode(self):
|
2015-08-11 11:51:26 +00:00
|
|
|
show = TVShow(1, 1, 'en')
|
|
|
|
show.name = 'show name'
|
|
|
|
show.tvrname = 'show name'
|
|
|
|
show.network = 'cbs'
|
|
|
|
show.genre = 'crime'
|
2014-03-10 05:18:05 +00:00
|
|
|
show.runtime = 40
|
2015-08-11 11:51:26 +00:00
|
|
|
show.status = '5'
|
|
|
|
show.airs = 'monday'
|
2014-03-10 05:18:05 +00:00
|
|
|
show.startyear = 1987
|
|
|
|
show.saveToDB()
|
|
|
|
sickbeard.showList = [show]
|
|
|
|
#TODO: implement
|
|
|
|
|
|
|
|
|
2017-08-20 22:16:25 +00:00
|
|
|
class TVFormatPatternTests(test.SickbeardTestDBCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TVFormatPatternTests, self).setUp()
|
|
|
|
sickbeard.showList = []
|
|
|
|
|
|
|
|
def test_getEpisode(self):
|
|
|
|
show = TVShow(1, 1, 'en')
|
|
|
|
show.name = 'show name'
|
|
|
|
show.tvrname = 'show name'
|
|
|
|
show.network = 'cbs'
|
|
|
|
show.genre = 'crime'
|
|
|
|
show.runtime = 40
|
|
|
|
show.status = '5'
|
|
|
|
show.airs = 'monday'
|
|
|
|
show.startyear = 1987
|
|
|
|
sickbeard.showList = [show]
|
|
|
|
show.episodes[1] = {}
|
|
|
|
show.episodes[1][1] = TVEpisode(show, 1, 1, '16)')
|
|
|
|
show.episodes[1][1].dirty = False
|
|
|
|
show.episodes[1][1].name = None
|
|
|
|
self.assertEqual(show.episodes[1][1].dirty, False)
|
|
|
|
self.assertEqual(show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'), 'show name - 1x01 - - Unknown')
|
|
|
|
show.episodes[1][1].dirty = False
|
|
|
|
show.episodes[1][1].name = 'ep name'
|
|
|
|
self.assertEqual(show.episodes[1][1].dirty, True)
|
|
|
|
self.assertEqual(show.episodes[1][1]._format_pattern('%SN - %Sx%0E - %EN - %QN'), 'show name - 1x01 - ep name - Unknown')
|
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
if __name__ == '__main__':
|
2015-06-09 11:13:00 +00:00
|
|
|
print('==================')
|
|
|
|
print('STARTING - TV TESTS')
|
|
|
|
print('==================')
|
|
|
|
print('######################################################################')
|
2014-03-10 05:18:05 +00:00
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TVShowTests)
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
2015-06-09 11:13:00 +00:00
|
|
|
print('######################################################################')
|
2014-03-10 05:18:05 +00:00
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TVEpisodeTests)
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
2015-06-09 11:13:00 +00:00
|
|
|
print('######################################################################')
|
2014-03-10 05:18:05 +00:00
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TVTests)
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|
2017-08-20 22:16:25 +00:00
|
|
|
print('######################################################################')
|
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TVFormatPatternTests)
|
|
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|