4 import rtv_propertiesfile
, rtv_programmeinfo
6 class Favourite(rtv_propertiesfile
.PropertiesFile
):
11 self
.not_channel
= None
12 self
.deleteAfterDays
= None
15 self
.destination
= None
16 self
.real_title
= None
17 self
.unique_subtitles
= True
23 def matches( self
, pi
):
25 if self
.title_re
is None:
26 return False # This favourite is empty
28 if self
._title
_re
is None:
29 self
._title
_re
= re
.compile( self
.title_re
+ "$" )
31 if not self
._title
_re
.match( pi
.title
):
34 if self
.channel
is not None and self
.channel
!= pi
.channel
:
38 # TODO: other things to match on e.g. time, categories
40 class FakeProg( object ):
41 def __init__( self
, title
, channel
):
43 self
.channel
= channel
45 def test_Empty_favourite_never_matches():
47 assert( not fav
.matches( FakeProg( "t", "c" ) ) )
49 def test_Wrong_title_doesnt_match():
51 fav
.title_re
= "other"
52 assert( not fav
.matches( FakeProg( "this", "c" ) ) )
54 def test_Right_title_matches():
57 assert( fav
.matches( FakeProg( "this", "c" ) ) )
59 def test_Wrong_channel_doesnt_match():
63 assert( not fav
.matches( FakeProg( "this", "c" ) ) )
65 def test_Right_channel_does_match():
69 assert( fav
.matches( FakeProg( "this", "c" ) ) )
72 test_Empty_favourite_never_matches()
73 test_Wrong_title_doesnt_match()
74 test_Right_title_matches()
75 test_Wrong_channel_doesnt_match()
76 test_Right_channel_does_match()