Refactor Reddit Gallery tests
This commit is contained in:
parent
bc7ccc0964
commit
3e9a846e2e
|
@ -1,22 +1,22 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
import praw.models
|
import praw
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bulkredditdownloader.resource import Resource
|
from bulkredditdownloader.resource import Resource
|
||||||
from bulkredditdownloader.site_downloaders.gallery import Gallery
|
from bulkredditdownloader.site_downloaders.gallery import Gallery
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
|
||||||
def reddit_submission(reddit_instance) -> praw.models.Submission:
|
|
||||||
return reddit_instance.submission(id='ljyy27')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.online
|
@pytest.mark.online
|
||||||
@pytest.mark.reddit
|
@pytest.mark.reddit
|
||||||
def test_gallery(reddit_submission: praw.models.Submission):
|
@pytest.mark.parametrize(('test_submission_id', 'expected_len'), (
|
||||||
gallery = Gallery(reddit_submission)
|
('ljyy27', 4),
|
||||||
|
('m6lvrh', 4),
|
||||||
|
))
|
||||||
|
def test_gallery(test_submission_id: str, expected_len: int, reddit_instance: praw.Reddit):
|
||||||
|
test_submission = reddit_instance.submission(id=test_submission_id)
|
||||||
|
gallery = Gallery(test_submission)
|
||||||
results = gallery.find_resources()
|
results = gallery.find_resources()
|
||||||
assert len(results) == 4
|
assert len(results) == expected_len
|
||||||
assert all([isinstance(result, Resource) for result in results])
|
assert all([isinstance(result, Resource) for result in results])
|
||||||
|
|
Loading…
Reference in a new issue