mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change test code to follow quotation standards
This commit is contained in:
parent
8eee9d8699
commit
03defe0219
10 changed files with 63 additions and 63 deletions
|
@ -19,7 +19,7 @@
|
|||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
import glob
|
||||
import unittest
|
||||
import sys
|
||||
|
|
|
@ -29,7 +29,7 @@ class DBBasicTests(test.SickbeardTestDBCase):
|
|||
self.db = test.db.DBConnection()
|
||||
|
||||
def test_select(self):
|
||||
self.db.select("SELECT * FROM tv_episodes WHERE showid = ? AND location != ''", [0000])
|
||||
self.db.select('SELECT * FROM tv_episodes WHERE showid = ? AND location != ""', [0000])
|
||||
self.db.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -86,7 +86,7 @@ class OldInitialSchema(db.SchemaUpgrade):
|
|||
logger.log_error_and_exit(u'Your database version ('
|
||||
+ str(cur_db_version)
|
||||
+ ') is too old to migrate from what this version of SickGear supports ('
|
||||
+ str(MIN_DB_VERSION) + ').' + "\n"
|
||||
+ str(MIN_DB_VERSION) + ').' + '\n'
|
||||
+ 'Upgrade using a previous version (tag) build 496 to build 501 of SickGear first or remove database file to begin fresh.'
|
||||
)
|
||||
|
||||
|
@ -94,7 +94,7 @@ class OldInitialSchema(db.SchemaUpgrade):
|
|||
logger.log_error_and_exit(u'Your database version ('
|
||||
+ str(cur_db_version)
|
||||
+ ') has been incremented past what this version of SickGear supports ('
|
||||
+ str(MAX_DB_VERSION) + ').' + "\n"
|
||||
+ str(MAX_DB_VERSION) + ').' + '\n'
|
||||
+ 'If you have used other forks of SickGear, your database may be unusable due to their modifications.'
|
||||
)
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ simple_test_cases = {
|
|||
'[ACX]Black Lagoon - 02v2 - Mangrove Heaven [SaintDeath] [7481F875]': parser.ParseResult(None, 'Black Lagoon', None, [], 'SaintDeath', 'ACX', None, [2]),
|
||||
},
|
||||
|
||||
"anime_standard_round": {
|
||||
'anime_standard_round': {
|
||||
'[SGKK] Bleach - 312v2 (1280x720 h264 AAC) [F501C9BE]': parser.ParseResult(None, 'Bleach', None, [], '1280x720 h264 AAC', 'SGKK', None, [312]),
|
||||
},
|
||||
|
||||
|
@ -160,7 +160,7 @@ simple_test_cases = {
|
|||
'[Ayako] Infinite Stratos - IS - 07v2 [H264][720p][44419534]': parser.ParseResult(None, 'Infinite Stratos', None, [], '720p', 'Ayako', None, [7]),
|
||||
'[Ayako-Shikkaku] Oniichan no Koto Nanka Zenzen Suki Janain Dakara ne - 10 [LQ][h264][720p] [8853B21C]': parser.ParseResult(None, 'Oniichan no Koto Nanka Zenzen Suki Janain Dakara ne', None, [], '720p', 'Ayako-Shikkaku', None, [10]),
|
||||
'[Tsuki] Fairy Tail - 72 [XviD][C4807111]': parser.ParseResult(None, 'Fairy Tail', None, [], 'C4807111', 'Tsuki', None, [72]),
|
||||
'Bubblegum Crisis Tokyo 2040 - 25 [aX] [F4E2E558]': parser.ParseResult(None, 'Bubblegum Crisis Tokyo 2040', None, [], "aX", None, None, [25]),
|
||||
'Bubblegum Crisis Tokyo 2040 - 25 [aX] [F4E2E558]': parser.ParseResult(None, 'Bubblegum Crisis Tokyo 2040', None, [], 'aX', None, None, [25]),
|
||||
|
||||
},
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class PPBasicTests(test.SickbeardTestDBCase):
|
|||
|
||||
sickbeard.showList = [show]
|
||||
ep = TVEpisode(show, test.SEASON, test.EPISODE)
|
||||
ep.name = "some ep name"
|
||||
ep.name = 'some ep name'
|
||||
ep.saveToDB()
|
||||
|
||||
addNameToCache('show name', 3)
|
||||
|
|
|
@ -30,9 +30,9 @@ import sickbeard
|
|||
from sickbeard.tv import TVEpisode, TVShow
|
||||
import sickbeard.common as c
|
||||
|
||||
tests = {"Dexter": {"a": 1, "q": c.HD, "s": 5, "e": [7], "b": 'Dexter.S05E07.720p.BluRay.X264-REWARD', "i": ['Dexter.S05E07.720p.BluRay.X264-REWARD', 'Dexter.S05E07.720p.X264-REWARD']},
|
||||
"House": {"a": 1, "q": c.HD, "s": 4, "e": [5], "b": 'House.4x5.720p.BluRay.X264-REWARD', "i": ['Dexter.S05E04.720p.X264-REWARD', 'House.4x5.720p.BluRay.X264-REWARD']},
|
||||
"Hells Kitchen": {"a": 1, "q": c.SD, "s": 6, "e": [14, 15], "b": 'Hells.Kitchen.s6e14e15.HDTV.XviD-ASAP', "i": ['Hells.Kitchen.S06E14.HDTV.XviD-ASAP', 'Hells.Kitchen.6x14.HDTV.XviD-ASAP', 'Hells.Kitchen.s6e14e15.HDTV.XviD-ASAP']}
|
||||
tests = {'Dexter': {'a': 1, 'q': c.HD, 's': 5, 'e': [7], 'b': 'Dexter.S05E07.720p.BluRay.X264-REWARD', 'i': ['Dexter.S05E07.720p.BluRay.X264-REWARD', 'Dexter.S05E07.720p.X264-REWARD']},
|
||||
'House': {'a': 1, 'q': c.HD, 's': 4, 'e': [5], 'b': 'House.4x5.720p.BluRay.X264-REWARD', 'i': ['Dexter.S05E04.720p.X264-REWARD', 'House.4x5.720p.BluRay.X264-REWARD']},
|
||||
'Hells Kitchen': {'a': 1, 'q': c.SD, 's': 6, 'e': [14, 15], 'b': 'Hells.Kitchen.s6e14e15.HDTV.XviD-ASAP', 'i': ['Hells.Kitchen.S06E14.HDTV.XviD-ASAP', 'Hells.Kitchen.6x14.HDTV.XviD-ASAP', 'Hells.Kitchen.s6e14e15.HDTV.XviD-ASAP']}
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,23 +69,23 @@ def test_generator(tvdbdid, show_name, curData, forceSearch):
|
|||
|
||||
def test(self):
|
||||
global searchItems
|
||||
searchItems = curData["i"]
|
||||
searchItems = curData['i']
|
||||
show = TVShow(1, tvdbdid)
|
||||
show.name = show_name
|
||||
show.quality = curData["q"]
|
||||
show.quality = curData['q']
|
||||
show.saveToDB()
|
||||
sickbeard.showList.append(show)
|
||||
episode = None
|
||||
|
||||
for epNumber in curData["e"]:
|
||||
episode = TVEpisode(show, curData["s"], epNumber)
|
||||
for epNumber in curData['e']:
|
||||
episode = TVEpisode(show, curData['s'], epNumber)
|
||||
episode.status = c.WANTED
|
||||
episode.saveToDB()
|
||||
|
||||
bestResult = search.searchProviders(show, episode.season, episode.episode, forceSearch)
|
||||
if not bestResult:
|
||||
self.assertEqual(curData["b"], bestResult)
|
||||
self.assertEqual(curData["b"], bestResult.name) #first is expected, second is choosen one
|
||||
self.assertEqual(curData['b'], bestResult)
|
||||
self.assertEqual(curData['b'], bestResult.name) #first is expected, second is choosen one
|
||||
return test
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -97,7 +97,7 @@ if __name__ == '__main__':
|
|||
tvdbdid = 1
|
||||
for forceSearch in (True, False):
|
||||
for name, curData in tests.items():
|
||||
if not curData["a"]:
|
||||
if not curData['a']:
|
||||
continue
|
||||
fname = name.replace(' ', '_')
|
||||
if forceSearch:
|
||||
|
|
|
@ -41,18 +41,18 @@ from sickbeard.databases import cache_db, failed_db
|
|||
# test globals
|
||||
#=================
|
||||
TESTDIR = os.path.abspath('.')
|
||||
TESTDBNAME = "sickbeard.db"
|
||||
TESTCACHEDBNAME = "cache.db"
|
||||
TESTFAILEDDBNAME = "failed.db"
|
||||
TESTDBNAME = 'sickbeard.db'
|
||||
TESTCACHEDBNAME = 'cache.db'
|
||||
TESTFAILEDDBNAME = 'failed.db'
|
||||
|
||||
SHOWNAME = u"show name"
|
||||
SHOWNAME = u'show name'
|
||||
SEASON = 4
|
||||
EPISODE = 2
|
||||
FILENAME = u"show name - s0" + str(SEASON) + "e0" + str(EPISODE) + ".mkv"
|
||||
FILENAME = u'show name - s0' + str(SEASON) + 'e0' + str(EPISODE) + '.mkv'
|
||||
FILEDIR = os.path.join(TESTDIR, SHOWNAME)
|
||||
FILEPATH = os.path.join(FILEDIR, FILENAME)
|
||||
|
||||
SHOWDIR = os.path.join(TESTDIR, SHOWNAME + " final")
|
||||
SHOWDIR = os.path.join(TESTDIR, SHOWNAME + ' final')
|
||||
|
||||
#sickbeard.logger.sb_log_instance = sickbeard.logger.SBRotatingLogHandler(os.path.join(TESTDIR, 'sickbeard.log'), sickbeard.logger.NUM_LOGS, sickbeard.logger.LOG_SIZE)
|
||||
sickbeard.logger.SBRotatingLogHandler.log_file = os.path.join(os.path.join(TESTDIR, 'Logs'), 'test_sickbeard.log')
|
||||
|
@ -85,7 +85,7 @@ sickbeard.NAMING_SPORTS_PATTERN = ''
|
|||
sickbeard.NAMING_MULTI_EP = 1
|
||||
|
||||
|
||||
sickbeard.PROVIDER_ORDER = ["sick_beard_index"]
|
||||
sickbeard.PROVIDER_ORDER = ['sick_beard_index']
|
||||
sickbeard.newznabProviderList = providers.getNewznabProviderList("'Sick Beard Index|http://lolo.sickbeard.com/|0|5030,5040,5060|0|eponly|0!!!NZBs.org|https://nzbs.org/||5030,5040,5060,5070,5090|0|eponly|0!!!Usenet-Crawler|https://www.usenet-crawler.com/||5030,5040,5060|0|eponly|0'")
|
||||
sickbeard.providerList = providers.makeProviderList()
|
||||
|
||||
|
@ -147,20 +147,20 @@ class TestCacheDBConnection(TestDBConnection, object):
|
|||
|
||||
# Create the table if it's not already there
|
||||
try:
|
||||
sql = "CREATE TABLE " + providerName + " (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT);"
|
||||
sql = 'CREATE TABLE ' + providerName + ' (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT);'
|
||||
self.connection.execute(sql)
|
||||
self.connection.commit()
|
||||
except sqlite3.OperationalError as e:
|
||||
if str(e) != "table " + providerName + " already exists":
|
||||
if str(e) != 'table ' + providerName + ' already exists':
|
||||
raise
|
||||
|
||||
# Create the table if it's not already there
|
||||
try:
|
||||
sql = "CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);"
|
||||
sql = 'CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);'
|
||||
self.connection.execute(sql)
|
||||
self.connection.commit()
|
||||
except sqlite3.OperationalError as e:
|
||||
if str(e) != "table lastUpdate already exists":
|
||||
if str(e) != 'table lastUpdate already exists':
|
||||
raise
|
||||
|
||||
# this will override the normal db connection
|
||||
|
@ -180,10 +180,10 @@ def setUp_test_db():
|
|||
db.sanityCheckDatabase(db.DBConnection(), mainDB.MainSanityCheck)
|
||||
|
||||
# and for cachedb too
|
||||
db.upgradeDatabase(db.DBConnection("cache.db"), cache_db.InitialSchema)
|
||||
db.upgradeDatabase(db.DBConnection('cache.db'), cache_db.InitialSchema)
|
||||
|
||||
# and for faileddb too
|
||||
db.upgradeDatabase(db.DBConnection("failed.db"), failed_db.InitialSchema)
|
||||
db.upgradeDatabase(db.DBConnection('failed.db'), failed_db.InitialSchema)
|
||||
|
||||
|
||||
def tearDown_test_db():
|
||||
|
@ -207,7 +207,7 @@ def setUp_test_episode_file():
|
|||
|
||||
try:
|
||||
with open(FILEPATH, 'w') as f:
|
||||
f.write("foo bar")
|
||||
f.write('foo bar')
|
||||
except EnvironmentError:
|
||||
print('Unable to set up test episode')
|
||||
raise
|
||||
|
@ -237,7 +237,7 @@ if __name__ == '__main__':
|
|||
|
||||
dirList = os.listdir(TESTDIR)
|
||||
for fname in dirList:
|
||||
if (fname.find("_test") > 0) and (fname.find("pyc") < 0):
|
||||
if (fname.find('_test') > 0) and (fname.find('pyc') < 0):
|
||||
print('- ' + fname)
|
||||
|
||||
print('==================')
|
||||
|
|
|
@ -41,7 +41,7 @@ class TorrentBasicTests(test.SickbeardTestDBCase):
|
|||
if not html:
|
||||
return
|
||||
|
||||
soup = BeautifulSoup(html, features=["html5lib", "permissive"])
|
||||
soup = BeautifulSoup(html, features=['html5lib', 'permissive'])
|
||||
|
||||
torrent_table = soup.find('table', attrs={'class': 'data'})
|
||||
torrent_rows = torrent_table.find_all('tr') if torrent_table else []
|
||||
|
@ -51,7 +51,7 @@ class TorrentBasicTests(test.SickbeardTestDBCase):
|
|||
|
||||
#Continue only if one Release is found
|
||||
if len(torrent_rows) < 2:
|
||||
print(u"The data returned does not contain any torrents")
|
||||
print(u'The data returned does not contain any torrents')
|
||||
return
|
||||
|
||||
for tr in torrent_rows[1:]:
|
||||
|
@ -71,7 +71,7 @@ class TorrentBasicTests(test.SickbeardTestDBCase):
|
|||
|
||||
print(title)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
print('==================')
|
||||
print('STARTING - XEM Scene Numbering TESTS')
|
||||
print('==================')
|
||||
|
|
|
@ -31,18 +31,18 @@ class TVShowTests(test.SickbeardTestDBCase):
|
|||
sickbeard.showList = []
|
||||
|
||||
def test_init_indexerid(self):
|
||||
show = TVShow(1, 1, "en")
|
||||
show = TVShow(1, 1, 'en')
|
||||
self.assertEqual(show.indexerid, 1)
|
||||
|
||||
def test_change_indexerid(self):
|
||||
show = TVShow(1, 1, "en")
|
||||
show.name = "show name"
|
||||
show.tvrname = "show name"
|
||||
show.network = "cbs"
|
||||
show.genre = "crime"
|
||||
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.status = '5'
|
||||
show.airs = 'monday'
|
||||
show.startyear = 1987
|
||||
|
||||
show.saveToDB()
|
||||
|
@ -55,11 +55,11 @@ class TVShowTests(test.SickbeardTestDBCase):
|
|||
self.assertEqual(show.indexerid, 2)
|
||||
|
||||
def test_set_name(self):
|
||||
show = TVShow(1, 1, "en")
|
||||
show.name = "newName"
|
||||
show = TVShow(1, 1, 'en')
|
||||
show.name = 'newName'
|
||||
show.saveToDB()
|
||||
show.loadFromDB(skipNFO=True)
|
||||
self.assertEqual(show.name, "newName")
|
||||
self.assertEqual(show.name, 'newName')
|
||||
|
||||
|
||||
class TVEpisodeTests(test.SickbeardTestDBCase):
|
||||
|
@ -69,12 +69,12 @@ class TVEpisodeTests(test.SickbeardTestDBCase):
|
|||
sickbeard.showList = []
|
||||
|
||||
def test_init_empty_db(self):
|
||||
show = TVShow(1, 1, "en")
|
||||
show = TVShow(1, 1, 'en')
|
||||
ep = TVEpisode(show, 1, 1)
|
||||
ep.name = "asdasdasdajkaj"
|
||||
ep.name = 'asdasdasdajkaj'
|
||||
ep.saveToDB()
|
||||
ep.loadFromDB(1, 1)
|
||||
self.assertEqual(ep.name, "asdasdasdajkaj")
|
||||
self.assertEqual(ep.name, 'asdasdasdajkaj')
|
||||
|
||||
|
||||
class TVTests(test.SickbeardTestDBCase):
|
||||
|
@ -84,14 +84,14 @@ class TVTests(test.SickbeardTestDBCase):
|
|||
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 = 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.status = '5'
|
||||
show.airs = 'monday'
|
||||
show.startyear = 1987
|
||||
show.saveToDB()
|
||||
sickbeard.showList = [show]
|
||||
|
|
|
@ -41,11 +41,11 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
|||
"""
|
||||
|
||||
myDB = test.db.DBConnection()
|
||||
sqlResults = myDB.select("SELECT * FROM tv_shows")
|
||||
sqlResults = myDB.select('SELECT * FROM tv_shows')
|
||||
|
||||
for sqlShow in sqlResults:
|
||||
try:
|
||||
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
|
||||
curShow = TVShow(int(sqlShow['indexer']), int(sqlShow['indexer_id']))
|
||||
sickbeard.showList.append(curShow)
|
||||
except Exception:
|
||||
pass
|
||||
|
@ -56,18 +56,18 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
|||
"""
|
||||
|
||||
myDB = test.db.DBConnection()
|
||||
sqlResults = myDB.select("SELECT * FROM tv_shows")
|
||||
sqlResults = myDB.select('SELECT * FROM tv_shows')
|
||||
|
||||
for sqlShow in sqlResults:
|
||||
try:
|
||||
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
|
||||
curShow = TVShow(int(sqlShow['indexer']), int(sqlShow['indexer_id']))
|
||||
sickbeard.showList.append(curShow)
|
||||
except Exception as e:
|
||||
print('There was an error creating the show')
|
||||
|
||||
def test_formating(self):
|
||||
name = "Game.of.Thrones.S03.720p.HDTV.x264-CtrlHD"
|
||||
release = "Game of Thrones"
|
||||
name = 'Game.of.Thrones.S03.720p.HDTV.x264-CtrlHD'
|
||||
release = 'Game of Thrones'
|
||||
|
||||
# m = re.match('(?P<ep_ab_num>(?>\d{1,3})(?![ip])).+', name)
|
||||
|
||||
|
@ -80,7 +80,7 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
|||
# print(u"Matched " + curRegex + " to " + name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
print('==================')
|
||||
print('STARTING - XEM Scene Numbering TESTS')
|
||||
print('==================')
|
||||
|
|
Loading…
Reference in a new issue