Merge branch 'master' of ssh://repo.or.cz/srv/git/recordtv
[recordtv.git] / src / test / schedule.py
blob4cb44e92f99183ed28a7a76b5539d3fb78166171
1 #!/usr/bin/python
3 import os
4 import os.path
5 import shutil
7 import rtv_schedule
9 original_old_dir = "test/files/norerecordold"
10 old_dir = "test/files/norerecordold-copy"
11 converted_dir = "test/files/norerecordconv"
13 def get_dir_tree( dr ):
14 ret = {}
15 for (dirpath, dirnames, filenames) in os.walk( dr ):
16 ret[dirpath] = filenames
17 return ret
19 def test_slow_find_old_programmes_map():
21 if os.path.isdir( old_dir ):
22 shutil.rmtree( old_dir )
24 shutil.copytree( original_old_dir, old_dir )
26 sch = rtv_schedule.Schedule( None )
28 old_converted_tree = get_dir_tree( converted_dir )
30 mp = sch.find_old_programmes_map( old_dir, converted_dir )
32 # We found the right titles and sub-titles
33 assert( mp == {
34 "Pocoyo" : { "Pato's Paintings" : 1,
35 "Monster Mystery" : 1, },
36 "The West Wing" : { "In the Room" : 1, },
37 "Thomas and Friends" : { "A Smooth Ride" : 1, },
38 } )
40 # We deleted the rtvinfos that didn't contain sub-titles
41 # or did contain unique_subtitles=False
42 dr_list = os.listdir( old_dir )
43 dr_list.sort()
45 assert( dr_list == [
46 "2008-10-10_Pato_s_Paintings.rtvinfo",
47 "2008-10-13_Monster_Mystery.rtvinfo",
48 "2008-11-16_In_the_Room.rtvinfo",
49 ] )
51 new_converted_tree = get_dir_tree( converted_dir )
53 assert( old_converted_tree == new_converted_tree )
55 shutil.rmtree( old_dir )
58 def test_slow():
59 test_slow_find_old_programmes_map()