forked from midgetspy/Sick-Beard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtv_tests.py
117 lines (94 loc) · 3.44 KB
/
tv_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# coding=UTF-8
# Author: Dennis Lutter <[email protected]>
# 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/>.
import random
import unittest
import test_lib as test
import sickbeard
from sickbeard.tv import TVEpisode, TVShow
from sickbeard import exceptions
class TVShowTests(test.SickbeardTestDBCase):
def setUp(self):
super(TVShowTests, self).setUp()
sickbeard.showList = []
def test_init_tvdbid(self):
show = TVShow(0001, "en")
self.assertEqual(show.tvdbid, 0001)
def test_change_tvdbid(self):
show = TVShow(0001, "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
show.saveToDB()
show.loadFromDB(skipNFO=True)
show.tvdbid = 0002
show.saveToDB()
show.loadFromDB(skipNFO=True)
self.assertEqual(show.tvdbid, 0002)
def test_set_name(self):
show = TVShow(0001, "en")
show.name = "newName"
show.saveToDB()
show.loadFromDB(skipNFO=True)
self.assertEqual(show.name, "newName")
class TVEpisodeTests(test.SickbeardTestDBCase):
def setUp(self):
super(TVEpisodeTests, self).setUp()
sickbeard.showList = []
def test_init_empty_db(self):
show = TVShow(0001, "en")
ep = TVEpisode(show, 1, 1)
ep.name = "asdasdasdajkaj"
ep.saveToDB()
ep.loadFromDB(1, 1)
self.assertEqual(ep.name, "asdasdasdajkaj")
class TVTests(test.SickbeardTestDBCase):
def setUp(self):
super(TVTests, self).setUp()
sickbeard.showList = []
def test_getEpisode(self):
show = TVShow(0001, "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
show.saveToDB()
sickbeard.showList = [show]
#TODO: implement
if __name__ == '__main__':
print "=================="
print "STARTING - TV TESTS"
print "=================="
print "######################################################################"
suite = unittest.TestLoader().loadTestsFromTestCase(TVShowTests)
unittest.TextTestRunner(verbosity=2).run(suite)
print "######################################################################"
suite = unittest.TestLoader().loadTestsFromTestCase(TVEpisodeTests)
unittest.TextTestRunner(verbosity=2).run(suite)
print "######################################################################"
suite = unittest.TestLoader().loadTestsFromTestCase(TVTests)
unittest.TextTestRunner(verbosity=2).run(suite)