def test_new_items_and_caching(self): # Analyze one RSS feed rssold = rssmodule.RSS(self.rssurl) olditems = rssold.getitems() oldrezults = self.manager.check4duplicates(items=olditems) self.assertGreater(len(oldrezults), 0) # Analyze the same RSS feed again rssnew = rssmodule.RSS(self.rssurl) newitems = rssnew.getitems() newrezults = self.manager.check4duplicates(items=newitems) self.assertEqual(0, len(newrezults))
def checkproviders(self): """Return uniq items from providers""" uniqitems = dict() for provider in settings.rssproviders: if self.testmode: provider = 'test' else: if provider == 'test': continue for key in settings.searchkeys: searchphrase = key.replace(' ', '%20') rssurl = settings.rssproviders[provider].format(searchphrase) logging.debug(rssurl) try: referrer = 'https://www.skytorrents.in/search/all/ad/1/?l=en-us&q={}'.format(key) rss = rssmodule.RSS(rssurl, referrer=referrer) except: logging.debug('Skipping') continue logging.debug(str(rss.count())) items = self.check4duplicates(items=rss.getitems()) for title in items: logging.debug(title) uniqitems[title] = items[title] time.sleep(self.timeout) return uniqitems
def setUp(self): self.cachedir = os.path.join('..', 'cachetest') self.manager = manager.Manager(cachedir=self.cachedir, pushurl='http://127.0.0.1/') self.manager.clearcache() self.rssurl = 'testrss.xml' self.rss = rssmodule.RSS(self.rssurl) self.rssitems = self.rss.getitems()
def test_read_rss_and_get_titles_and_links(self): # Read RSS and discover several items rss = rssmodule.RSS(url=self.rssurl) self.assertGreater(rss.count(), 0) # Get titles of the RSS items titles = rss.gettitles() self.assertGreater(len(titles), 0) # Check if the titles are relevant for title in titles: self.assertIn(self.searchkey, title.lower()) self.assertIn(self.year, title.lower()) # Get magnet links items = rss.getitems() for title in items.keys(): link = items[title] self.assertIn('magnet:?xt=urn:btih:', link)
def setUp(self): self.rssurl = 'testrss.xml' self.rss = rssmodule.RSS(self.rssurl)