mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-22 05:17:59 +01:00
Add redactor to Fimfiction APIv2 fetcher tests
This commit is contained in:
parent
3139ff9d7c
commit
d9a0a78c79
1 changed files with 20 additions and 0 deletions
|
@ -29,6 +29,9 @@ import pytest
|
||||||
|
|
||||||
from fimfarchive.exceptions import InvalidStoryError
|
from fimfarchive.exceptions import InvalidStoryError
|
||||||
from fimfarchive.fetchers import Fimfiction2Fetcher
|
from fimfarchive.fetchers import Fimfiction2Fetcher
|
||||||
|
from fimfarchive.utils import JayWalker
|
||||||
|
|
||||||
|
from tests.fixtures.responses import Recorder
|
||||||
|
|
||||||
|
|
||||||
VALID_STORY_KEY = 9
|
VALID_STORY_KEY = 9
|
||||||
|
@ -54,6 +57,20 @@ BULK_COMBINATIONS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Redactor(JayWalker):
|
||||||
|
"""
|
||||||
|
Redacts recorded responses.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def handle(self, data, key, value) -> None:
|
||||||
|
key = str(key)
|
||||||
|
|
||||||
|
if key.endswith('_html') or key == 'short_description':
|
||||||
|
data[key] = "REDACTED"
|
||||||
|
else:
|
||||||
|
self.walk(value)
|
||||||
|
|
||||||
|
|
||||||
class TestFimfiction2Fetcher:
|
class TestFimfiction2Fetcher:
|
||||||
"""
|
"""
|
||||||
Fimfarchive2Fetcher tests.
|
Fimfarchive2Fetcher tests.
|
||||||
|
@ -72,6 +89,9 @@ class TestFimfiction2Fetcher:
|
||||||
fetcher.prefetch_meta = False
|
fetcher.prefetch_meta = False
|
||||||
fetcher.prefetch_data = False
|
fetcher.prefetch_data = False
|
||||||
|
|
||||||
|
if isinstance(responses, Recorder):
|
||||||
|
responses.walker = Redactor()
|
||||||
|
|
||||||
yield fetcher
|
yield fetcher
|
||||||
|
|
||||||
def fetch_valid(self, fetcher, key):
|
def fetch_valid(self, fetcher, key):
|
||||||
|
|
Loading…
Reference in a new issue