Ejemplo n.º 1
0
    def test_parse_low_quality_episodes_from_feed(self):
        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 0)
Ejemplo n.º 2
0
    def test_parse_single_episodes_from_feed(self):
        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 1)
            self.assertEqual(episodes[0].title, 'testshow')
Ejemplo n.º 3
0
    def test_queue_ordering(self):
        """Test if tasks are retrieved from the queue in the correct order"""
        queue = PriorityQueue()
        taskscheduler = TaskScheduler(queue)
        taskrunner = TaskRunner(queue)

        # Create 3 tasks with different priority
        task_one = RSSFeedParserTask()
        task_one.priority = BaseTask.PRIORITY_LOW

        task_two = RSSFeedParserTask()
        task_two.priority = BaseTask.PRIORITY_NORMAL

        task_three = RSSFeedParserTask()
        task_three.priority = BaseTask.PRIORITY_HIGH

        # Add all tasks to the queue
        taskscheduler._add_to_queue(task_one)
        taskscheduler._add_to_queue(task_two)
        taskscheduler._add_to_queue(task_three)

        # Make sure only our 3 tasks are in the queue
        self.assertEqual(taskscheduler._queue.qsize(), 3)

        # Check order of tasks in queue, PRIORITY_HIGH should be first
        _, task = taskrunner._queue.get(block=False)
        self.assertEqual(task.priority, BaseTask.PRIORITY_HIGH)

        _, task = taskrunner._queue.get(block=False)
        self.assertEqual(task.priority, BaseTask.PRIORITY_NORMAL)

        _, task = taskrunner._queue.get(block=False)
        self.assertEqual(task.priority, BaseTask.PRIORITY_LOW)
Ejemplo n.º 4
0
    def test_follow_from_is_followed(self):
        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.follow_from_season = 2
            show.follow_from_episode = 2
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 1)
            self.assertEqual(episodes[0].title, 'testshow')

        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.follow_from_season = 3
            show.follow_from_episode = 2
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 0)

        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.follow_from_season = 2
            show.follow_from_episode = 5
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 0)
Ejemplo n.º 5
0
    def test_save_already_downloaded_episode(self):
        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.save()

            episode = self._get_new_dummy_episode(show)
            episode.season = 2
            episode.episode = 3
            episode.quality = 1080
            episode.is_downloaded = True
            episode.save()

            rssfeedparsertask = RSSFeedParserTask()
            rssfeedparsertask._deferred()

            episodes = rssfeedparsertask._parse_episodes_from_feed()
            self.assertEqual(len(episodes), 0)
Ejemplo n.º 6
0
    def test_parse_multiple_full_episodes_from_feed(self):
        with test_database(database, (Show, Episode)):
            show = self._get_new_dummy_show()
            show.save()

            rssfeedparsertask = RSSFeedParserTask()
            episodes = rssfeedparsertask._parse_episodes_from_feed()

            self.assertEqual(len(episodes), 3)

            self.assertEqual(episodes[0].title, 'testshow')
            self.assertEqual(episodes[0].season, 2)
            self.assertEqual(episodes[0].episode, 3)
            self.assertEqual(episodes[0].quality, 720)

            self.assertEqual(episodes[1].title, 'testshow')
            self.assertEqual(episodes[1].season, 2)
            self.assertEqual(episodes[1].episode, 3)
            self.assertEqual(episodes[1].quality, 1080)

            self.assertEqual(episodes[2].title, 'testshow')
            self.assertEqual(episodes[2].season, 2)
            self.assertEqual(episodes[2].episode, 3)
            self.assertEqual(episodes[2].quality, 720)
Ejemplo n.º 7
0
 def _add_rssfeedparsertask(self):
     self._add_to_queue(RSSFeedParserTask())