Example #1
0
 def testXkcd(self):
     links = parser.findLinks(
         "http://xkcd.com/500/",
         "http://xkcd.com/501/")
     self.assertEqual(parser.getNext(
         "http://xkcd.com/25/", links[0][0], links[0][1])
         ,"http://xkcd.com/26/")
Example #2
0
 def testQuestionableContent(self):
     links = parser.findLinks(
         "http://www.questionablecontent.net/view.php?comic=1428",
         "http://www.questionablecontent.net/view.php?comic=1429")
     self.assertEqual(parser.getNext(
         "http://www.questionablecontent.net/view.php?comic=1430", links[0][0], links[0][1]),
         "http://www.questionablecontent.net/view.php?comic=1431")
Example #3
0
 def checkNewEpisode(self):
     """Checks if a comic has a new episode, and, if so, update the comic"""
     if self.strategy == "N":
         last_episode = self.episode_set.order_by("-order")[0]
         next_comic_url = parser.getNext(
             last_episode.url,
             self.next_button_xpath,
             self.next_button_expected_html,
         )
         if next_comic_url:
             e = Episode()
             e.comic = self
             e.order = last_episode.order + 1
             e.url = next_comic_url
             if self.episode_title_xpath:
                 e.title = parser.getTextForXpath(next_comic_url, self.episode_title_xpath)
             else:
                 # TODO
                 pass
             e.save()
             return True            
     return False
Example #4
0
 def testNextInSecond(self):
     """getNext should return a link to the third page"""
     next = parser.getNext(TESTCOMIC[2], self.xpath, self.expected_html)
     self.assertTrue(next)
     self.assertEqual(next, TESTCOMIC[3])
Example #5
0
 def testNextOnFirst(self):
     """getNext should also not work on the first page (because the links are shifted)"""
     self.assertFalse(
         parser.getNext(TESTCOMIC[1], self.xpath, self.expected_html))
Example #6
0
 def testNextOnLast(self):
     """getNext should not return a link if we are on the last one"""
     self.assertFalse(
         parser.getNext(TESTCOMIC[4], self.xpath, self.expected_html))