test_archiver.py 785 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. # coding=utf-8
  3. from pathlib import Path
  4. from unittest.mock import MagicMock
  5. import praw
  6. import pytest
  7. from bdfr.archiver import Archiver
  8. @pytest.mark.online
  9. @pytest.mark.reddit
  10. @pytest.mark.parametrize(('test_submission_id', 'test_format'), (
  11. ('m3reby', 'xml'),
  12. ('m3reby', 'json'),
  13. ('m3reby', 'yaml'),
  14. ))
  15. def test_write_submission_json(test_submission_id: str, tmp_path: Path, test_format: str, reddit_instance: praw.Reddit):
  16. archiver_mock = MagicMock()
  17. archiver_mock.args.format = test_format
  18. test_path = Path(tmp_path, 'test')
  19. test_submission = reddit_instance.submission(id=test_submission_id)
  20. archiver_mock.file_name_formatter.format_path.return_value = test_path
  21. Archiver.write_entry(archiver_mock, test_submission)