test_self_post.py 798 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. # coding=utf-8
  3. import praw
  4. import pytest
  5. from bdfr.resource import Resource
  6. from bdfr.site_downloaders.self_post import SelfPost
  7. @pytest.mark.online
  8. @pytest.mark.reddit
  9. @pytest.mark.parametrize(('test_submission_id', 'expected_hash'), (
  10. ('ltmivt', '7d2c9e4e989e5cf2dca2e55a06b1c4f6'),
  11. ('ltoaan', '221606386b614d6780c2585a59bd333f'),
  12. ('d3sc8o', 'c1ff2b6bd3f6b91381dcd18dfc4ca35f'),
  13. ))
  14. def test_find_resource(test_submission_id: str, expected_hash: str, reddit_instance: praw.Reddit):
  15. submission = reddit_instance.submission(id=test_submission_id)
  16. downloader = SelfPost(submission)
  17. results = downloader.find_resources()
  18. assert len(results) == 1
  19. assert isinstance(results[0], Resource)
  20. assert results[0].hash.hexdigest() == expected_hash