Exemplo n.º 1
0
    def test_extract_direct(self, filter_content, make_title, make_dir_path):
        url = 'https://imgur.com/fb2yRj0.jpg'
        post = get_post(url=url, session=self.session)
        filter_content.return_value = True
        make_title.return_value = post.title
        make_dir_path.return_value = 'content_dir_path'

        ie = ImgurExtractor(post)
        ie.extract_direct_link()

        self.check_output(ie, url, post)
Exemplo n.º 2
0
    def test_imgur_runtime_unknown_error(self, img_mock, filter_content,
                                         make_title, make_dir_path):
        img_mock.side_effect = RuntimeError()

        ie = ImgurExtractor(self.get_single_post())
        ie.extract_content()

        self.assertTrue(ie.failed_extraction)
        self.assertIsNotNone(ie.failed_extraction_message)
        self.assertEqual(0, len(ie.extracted_content))
        self.assertTrue('failed to extract content' in
                        ie.failed_extraction_message.lower())
Exemplo n.º 3
0
    def test_imgur_down_error(self, img_mock, filter_content, make_title,
                              make_dir_path):
        img_mock.side_effect = ImgurError(status_code=500)

        ie = ImgurExtractor(self.get_single_post())
        ie.extract_content()

        self.assertTrue(ie.failed_extraction)
        self.assertIsNotNone(ie.failed_extraction_message)
        self.assertEqual(0, len(ie.extracted_content))
        self.assertTrue(
            'over capacity' in ie.failed_extraction_message.lower())
Exemplo n.º 4
0
    def test_extract_direct_unknown_ext(self, filter_content, make_title,
                                        make_dir_path):
        post = get_post(url='https://i.imgur.com/fb2yRj0.foo')
        filter_content.return_value = True
        make_title.return_value = post.title
        make_dir_path.return_value = 'content_dir_path'
        ie = ImgurExtractor(post)
        ie.extract_direct_link()

        self.assertTrue(ie.failed_extraction)
        self.assertIsNotNone(ie.failed_extraction_message)
        self.assertEqual(0, len(ie.extracted_content))
Exemplo n.º 5
0
    def test_extract_direct_gif(self, filter_content, make_title,
                                make_dir_path):
        in_url = 'https://i.imgur.com/mOlfhY3.gif'
        out_url = 'https://i.imgur.com/mOlfhY3.mp4'
        post = get_post(url=in_url, session=self.session)
        filter_content.return_value = True
        make_title.return_value = post.title
        make_dir_path.return_value = 'content_dir_path'

        ie = ImgurExtractor(post)
        ie.extract_direct_link()

        self.check_output(ie, out_url, post)