Ejemplo n.º 1
0
    def test_forum_thread_from_content(self):
        content = self.load_resource(FILE_THREAD)

        thread = ForumThread.from_content(content)

        self.assertEqual("News: Team Finder, Visualisation of Loot Lists",
                         thread.title)
        self.assertEqual(4797985, thread.thread_id)
        self.assertEqual('Auditorium (English Only)', thread.board)
        self.assertEqual('Community Boards', thread.section)
        self.assertEqual(4796826, thread.previous_topic_number)
        self.assertEqual(4797838, thread.next_topic_number)
        self.assertEqual(1, thread.page)
        self.assertEqual(9, thread.total_pages)
        self.assertEqual(20, len(thread.posts))
        self.assertIsNotNone(thread.url)
        self.assertIsNone(thread.previous_page_url)
        self.assertIsNotNone(thread.next_page_url)
        self.assertIsNotNone(thread.previous_thread_url)
        self.assertIsNotNone(thread.next_thread_url)

        post = thread.posts[0]
        self.assertEqual("Skerio", post.author.name)
        self.assertEqual("Relania", post.author.world)
        self.assertEqual("Community Manager", post.author.position)
        self.assertEqual(711, post.author.posts)
        self.assertEqual("Mirade", post.edited_by)
        self.assertTrue(post.golden_frame)
        self.assertEqual(38969385, post.post_id)
        self.assertIsNotNone(post.url)

        with self.assertRaises(ValueError):
            thread.get_page_url(-1)
Ejemplo n.º 2
0
    def test_forum_thread_from_content_invalid_page(self):
        content = self.load_resource(FILE_THREAD_INVALID_PAGE)

        thread = ForumThread.from_content(content)

        self.assertEqual("News: Te...", thread.title)
        self.assertEqual(0, thread.thread_id)
        self.assertEqual('Auditorium (English Only)', thread.board)
        self.assertEqual('Community Boards', thread.section)
        self.assertEqual(0, thread.previous_topic_number)
        self.assertEqual(0, thread.next_topic_number)
        self.assertEqual(1, thread.page)
        self.assertEqual(1, thread.total_pages)
        self.assertEqual(0, len(thread.posts))
Ejemplo n.º 3
0
    def test_forum_thread_from_content_unrelated_section(self):
        content = self.load_resource(self.FILE_UNRELATED_SECTION)

        with self.assertRaises(InvalidContent):
            ForumThread.from_content(content)
Ejemplo n.º 4
0
    def test_forum_thread_from_content_not_found(self):
        content = self.load_resource(FILE_THREAD_NOT_FOUND)

        thread = ForumThread.from_content(content)

        self.assertIsNone(thread)