Add object type filtering to iter_resources
This commit is contained in:
parent
63da39e005
commit
bfb3689456
16 changed files with 92 additions and 61 deletions
|
|
@ -62,15 +62,16 @@ class NovaBackend(BaseBackend, ICapRadio, ICapCollection):
|
|||
_RADIOS = {'nova': (u'Radio Nova', u'Radio nova', u'http://broadcast.infomaniak.net:80/radionova-high.mp3'),
|
||||
}
|
||||
|
||||
def iter_resources(self, split_path):
|
||||
if len(split_path) > 0:
|
||||
raise CollectionNotFound(split_path)
|
||||
def iter_resources(self, objs, split_path):
|
||||
if Radio in objs:
|
||||
if len(split_path) > 0:
|
||||
raise CollectionNotFound(split_path)
|
||||
|
||||
for id in self._RADIOS.iterkeys():
|
||||
yield self.get_radio(id)
|
||||
for id in self._RADIOS.iterkeys():
|
||||
yield self.get_radio(id)
|
||||
|
||||
def iter_radios_search(self, pattern):
|
||||
for radio in self.iter_resources([]):
|
||||
for radio in self.iter_resources((Radio, ), []):
|
||||
if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower():
|
||||
yield radio
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,11 @@
|
|||
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
from weboob.capabilities.radio import Radio
|
||||
|
||||
class NovaTest(BackendTest):
|
||||
BACKEND = 'nova'
|
||||
|
||||
def test_nova(self):
|
||||
l = list(self.backend.iter_resources([]))
|
||||
l = list(self.backend.iter_resources((Radio, ), []))
|
||||
self.assertTrue(len(l) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue