test_direct.py 818 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python3
  2. # coding=utf-8
  3. from unittest.mock import Mock
  4. import pytest
  5. from bdfr.resource import Resource
  6. from bdfr.site_downloaders.direct import Direct
  7. @pytest.mark.online
  8. @pytest.mark.parametrize(('test_url', 'expected_hash'), (
  9. ('https://giant.gfycat.com/DefinitiveCanineCrayfish.mp4', '48f9bd4dbec1556d7838885612b13b39'),
  10. ('https://giant.gfycat.com/DazzlingSilkyIguana.mp4', '808941b48fc1e28713d36dd7ed9dc648'),
  11. ))
  12. def test_download_resource(test_url: str, expected_hash: str):
  13. mock_submission = Mock()
  14. mock_submission.url = test_url
  15. test_site = Direct(mock_submission)
  16. resources = test_site.find_resources()
  17. assert len(resources) == 1
  18. assert isinstance(resources[0], Resource)
  19. resources[0].download()
  20. assert resources[0].hash.hexdigest() == expected_hash