Integrate new base_downloader class

This commit is contained in:
Serene-Arc
2021-02-25 20:40:08 +10:00
committed by Ali Parlakci
parent a75e94e43e
commit e0d321c785
13 changed files with 70 additions and 93 deletions

View File

@@ -1,30 +0,0 @@
#!/usr/bin/env python3
# coding=utf-8
from pathlib import Path
from unittest.mock import Mock
import pytest
from bulkredditdownloader.resource import Resource
from bulkredditdownloader.site_downloaders.base_downloader import BaseDownloader
class BlankDownloader(BaseDownloader):
def __init__(self, post):
super().__init__(post)
def download(self) -> list[Resource]:
return [self._download_resource(self.post.url)]
@pytest.mark.parametrize(('test_url', 'expected_hash'), (
('https://docs.python.org/3/_static/py.png', 'a721fc7ec672275e257bbbfde49a4d4e'),
))
def test_get_resource(test_url: str, expected_hash: str):
mock_submission = Mock
mock_submission.url = test_url
downloader = BlankDownloader(mock_submission)
result = downloader.download()
assert isinstance(result[0], Resource)
assert result[0].hash.hexdigest() == expected_hash

View File

@@ -15,6 +15,6 @@ def reddit_submission(reddit_instance) -> praw.models.Submission:
def test_gallery(reddit_submission: praw.models.Submission):
gallery = Gallery(reddit_submission)
results = gallery.download()
results = gallery.find_resources()
assert len(results) == 4
assert all([isinstance(result, Resource) for result in results])