2021-03-13 23:18:30 +13:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
import praw
|
|
|
|
import pytest
|
|
|
|
|
2021-04-12 19:58:32 +12:00
|
|
|
from bdfr.archiver import Archiver
|
2021-03-13 23:18:30 +13:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.online
|
|
|
|
@pytest.mark.reddit
|
2021-05-17 13:04:24 +12:00
|
|
|
@pytest.mark.parametrize(('test_submission_id', 'test_format'), (
|
|
|
|
('m3reby', 'xml'),
|
|
|
|
('m3reby', 'json'),
|
|
|
|
('m3reby', 'yaml'),
|
2021-03-13 23:18:30 +13:00
|
|
|
))
|
2021-05-17 13:04:24 +12:00
|
|
|
def test_write_submission_json(test_submission_id: str, tmp_path: Path, test_format: str, reddit_instance: praw.Reddit):
|
2021-03-13 23:18:30 +13:00
|
|
|
archiver_mock = MagicMock()
|
2021-05-17 13:04:24 +12:00
|
|
|
archiver_mock.args.format = test_format
|
|
|
|
test_path = Path(tmp_path, 'test')
|
2021-03-13 23:18:30 +13:00
|
|
|
test_submission = reddit_instance.submission(id=test_submission_id)
|
|
|
|
archiver_mock.file_name_formatter.format_path.return_value = test_path
|
2021-05-17 13:04:24 +12:00
|
|
|
Archiver.write_entry(archiver_mock, test_submission)
|