Add object type filtering to iter_resources

This commit is contained in:
Laurent Bachelier 2012-02-05 13:30:02 +01:00
commit bfb3689456
16 changed files with 92 additions and 61 deletions

View file

@ -22,7 +22,7 @@ from __future__ import with_statement
import re
from weboob.capabilities.video import ICapVideo
from weboob.capabilities.video import ICapVideo, BaseVideo
from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.value import Value
@ -71,6 +71,7 @@ class CanalplusBackend(BaseBackend, ICapVideo, ICapCollection):
OBJECTS = {CanalplusVideo: fill_video}
def iter_resources(self, split_path):
with self.browser:
return self.browser.iter_resources(split_path)
def iter_resources(self, objs, split_path):
if BaseVideo in objs:
with self.browser:
return self.browser.iter_resources(split_path)

View file

@ -19,6 +19,7 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.video import BaseVideo
class CanalPlusTest(BackendTest):
BACKEND = 'canalplus'
@ -29,3 +30,10 @@ class CanalPlusTest(BackendTest):
v = l[0]
self.backend.fillobj(v, ('url',))
self.assertTrue(v.url and v.url.startswith('rtmp://'), 'URL for video "%s" not found: %s' % (v.id, v.url))
def test_ls(self):
l = list(self.backend.iter_resources((BaseVideo, ), []))
self.assertTrue(len(l) > 0)
l = list(self.backend.iter_resources((BaseVideo, ), ['SPORT']))
self.assertTrue(len(l) > 0)