From e48e6fa819928dc3774ad82ec7b0346e8b6751ee Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Sat, 17 Sep 2011 17:35:55 +0100 Subject: [PATCH] Allow specifying a "not_channel" on a favourite. --- src/rtv_favourite.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/rtv_favourite.py b/src/rtv_favourite.py index 10922d2..87d9237 100644 --- a/src/rtv_favourite.py +++ b/src/rtv_favourite.py @@ -31,6 +31,9 @@ class Favourite(rtv_propertiesfile.PropertiesFile): if not self._title_re.match( pi.title ): return False + if self.not_channel is not None and self.not_channel == pi.channel: + return False + if self.channel is not None and self.channel != pi.channel: return False @@ -68,10 +71,24 @@ def test_Right_channel_does_match(): fav.channel = "c" assert( fav.matches( FakeProg( "this", "c" ) ) ) +def test_Not_channel_excludes(): + fav = Favourite() + fav.title_re = "this" + fav.not_channel = "Dave" + assert( not fav.matches( FakeProg( "this", "Dave" ) ) ) + +def test_Unmatching_not_channel_doesnt_exclude(): + fav = Favourite() + fav.title_re = "this" + fav.not_channel = "Dave" + assert( fav.matches( FakeProg( "this", "BBC One" ) ) ) + def test( config ): test_Empty_favourite_never_matches() test_Wrong_title_doesnt_match() test_Right_title_matches() test_Wrong_channel_doesnt_match() test_Right_channel_does_match() + test_Not_channel_excludes() + test_Unmatching_not_channel_doesnt_exclude() -- 2.11.4.GIT