forked from Sakartu/sicksubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·57 lines (50 loc) · 1.9 KB
/
test.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
#!/usr/bin/env python
import unittest
import db
import sicksubs
import sys
import os
import glob
import shutil
workdir = '/tmp/sicksubs_test/'
interm = os.path.join(workdir, 'interm')
final = os.path.join(workdir, 'final')
class SickSubsTests(unittest.TestCase):
def setUp(self):
self.conn = db.initialize('/tmp/sicksubs_test/test.db')
os.makedirs(interm)
os.makedirs(final)
os.system('touch ' + os.path.join(interm, 'White.Collar.S02E04.DVDRip.XviD-SAiNTS.avi'))
os.system('touch ' + os.path.join(final, 'White.Collar.S02E04.By.the.Book.avi '))
def tearDown(self):
shutil.rmtree(workdir)
def test_found(self):
# existing ep
sys.argv = [os.path.join(os.path.abspath('.'), sys.argv[0]),
'/tmp/sicksubs_test/final/White.Collar.S02E04.By.the.Book.avi',
'/tmp/sicksubs_test/interm/White.Collar.S02E04.DVDRip.XviD-SAiNTS.avi',
'108611',
'2',
'5',
'03-09-2010'
]
# no need to run the cron run, the sickbeard run will do that for us
sicksubs.sickbeard_run(self.conn)
self.assertTrue(os.path.exists(final + '/White.Collar.S02E04.By.the.Book.srt'))
self.assertTrue(os.path.exists(final + '/White.Collar.S02E04.By.the.Book.avi.works'))
def test_not_found(self):
# use a non existing ep
sys.argv = [os.path.join(os.path.abspath('.'), sys.argv[0]),
'/tmp/sicksubs_test/final/White.Collar.S02E40.By.the.Book.avi',
'/tmp/sicksubs_test/interm/White.Collar.S02E40.DVDRip.XviD-SAiNTS.avi',
'108611',
'2',
'5',
'03-09-2010'
]
# no need to run the cron run, the sickbeard run will do that for us
sicksubs.sickbeard_run(self.conn)
self.assertEqual([], glob.glob(final + '/*.srt'))
self.assertEqual([], glob.glob(final + '/*.works'))
if __name__ == '__main__':
tests = unittest.main()