mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
e06e671d67
This fix correctly places the local libraries at the start of the sys.path such that they are loaded instead of any libraries that may already exist on the users system. This prevents the issue where a system library that isn't supported by SickGear is loaded and causes errors during operation.
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import sys
|
|
import os.path
|
|
import glob
|
|
import unittest
|
|
import test_lib as test
|
|
import sickbeard
|
|
from time import sleep
|
|
from sickbeard import db
|
|
|
|
sys.path.insert(1, os.path.abspath('..'))
|
|
sys.path.insert(1, os.path.abspath('../lib'))
|
|
|
|
sickbeard.SYS_ENCODING = 'UTF-8'
|
|
|
|
|
|
class MigrationBasicTests(test.SickbeardTestDBCase):
|
|
def setUp(self):
|
|
pass
|
|
|
|
def tearDown(self):
|
|
pass
|
|
|
|
def test_migrations(self):
|
|
schema = {
|
|
0: sickbeard.mainDB.InitialSchema,
|
|
31: sickbeard.mainDB.AddAnimeTVShow,
|
|
32: sickbeard.mainDB.AddAbsoluteNumbering,
|
|
33: sickbeard.mainDB.AddSceneAbsoluteNumbering,
|
|
34: sickbeard.mainDB.AddAnimeBlacklistWhitelist,
|
|
35: sickbeard.mainDB.AddSceneAbsoluteNumbering2,
|
|
36: sickbeard.mainDB.AddXemRefresh,
|
|
37: sickbeard.mainDB.AddSceneToTvShows,
|
|
38: sickbeard.mainDB.AddIndexerMapping,
|
|
39: sickbeard.mainDB.AddVersionToTvEpisodes,
|
|
41: AddDefaultEpStatusToTvShows,
|
|
}
|
|
|
|
count = 1
|
|
while count < len(schema.keys()):
|
|
myDB = db.DBConnection()
|
|
|
|
for version in sorted(schema.keys())[:count]:
|
|
update = schema[version](myDB)
|
|
update.execute()
|
|
sleep(0.1)
|
|
|
|
db.MigrationCode(myDB)
|
|
myDB.close()
|
|
for filename in glob.glob(os.path.join(test.TESTDIR, test.TESTDBNAME) +'*'):
|
|
os.remove(filename)
|
|
|
|
sleep(0.1)
|
|
count += 1
|
|
|
|
|
|
class AddDefaultEpStatusToTvShows(db.SchemaUpgrade):
|
|
def execute(self):
|
|
self.addColumn("tv_shows", "default_ep_status", "TEXT", "")
|
|
self.setDBVersion(41)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print "=================="
|
|
print "STARTING - MIGRATION TESTS"
|
|
print "=================="
|
|
print "######################################################################"
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(MigrationBasicTests)
|
|
unittest.TextTestRunner(verbosity=2).run(suite)
|