Move the "empty search for latest" to collections

There is now a "latest" collection (or "latest_nsfw").
The feature didn't look much used, since it didn't work on many
backends.
Using collections will make it easy to support other things
like most viewed, featured, etc.
As a bonus, I added tests for every backend with the feature.
This commit is contained in:
Laurent Bachelier 2012-03-16 02:55:58 +01:00
commit e958c229e6
32 changed files with 366 additions and 112 deletions

View file

@ -19,12 +19,15 @@
from weboob.tools.test import BackendTest
from weboob.capabilities.video import BaseVideo
from .pages.video import ForbiddenVideo
class NolifeTVTest(BackendTest):
BACKEND = 'nolifetv'
def test_nolife(self):
def test_search(self):
l = list(self.backend.search_videos('nolife'))
self.assertTrue(len(l) > 0)
for v in l:
@ -35,3 +38,15 @@ class NolifeTVTest(BackendTest):
else:
self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url))
break
def test_latest(self):
l = list(self.backend.iter_resources([BaseVideo], [u'latest']))
assert len(l) > 0
for v in l:
try:
self.backend.fillobj(v, ('url',))
except ForbiddenVideo:
continue
else:
self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url))
break