mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-22 05:17:59 +01:00
Write only meta for revived stories in update task
This commit is contained in:
parent
2270df477b
commit
c604c4b2ad
2 changed files with 23 additions and 3 deletions
|
@ -28,7 +28,7 @@ from typing import Optional
|
|||
|
||||
from fimfarchive.exceptions import InvalidStoryError
|
||||
from fimfarchive.fetchers import Fetcher
|
||||
from fimfarchive.flavors import DataFormat, UpdateStatus
|
||||
from fimfarchive.flavors import DataFormat, StorySource, UpdateStatus
|
||||
from fimfarchive.mappers import StoryPathMapper
|
||||
from fimfarchive.selectors import Selector, UpdateSelector
|
||||
from fimfarchive.signals import Signal, SignalSender
|
||||
|
@ -119,6 +119,7 @@ class UpdateTask(SignalSender):
|
|||
html_mapper = self.get_mapper('html')
|
||||
json_mapper = self.get_mapper('json')
|
||||
|
||||
self.meta_writer = DirectoryWriter(meta_mapper)
|
||||
self.skip_writer = DirectoryWriter(skip_mapper)
|
||||
self.epub_writer = DirectoryWriter(meta_mapper, epub_mapper)
|
||||
self.html_writer = DirectoryWriter(meta_mapper, html_mapper)
|
||||
|
@ -160,7 +161,9 @@ class UpdateTask(SignalSender):
|
|||
Raises:
|
||||
ValueError: If story flavor is unsupported.
|
||||
"""
|
||||
if DataFormat.HTML in story.flavors:
|
||||
if StorySource.FIMFARCHIVE in story.flavors:
|
||||
self.meta_writer.write(story)
|
||||
elif DataFormat.HTML in story.flavors:
|
||||
self.html_writer.write(story)
|
||||
elif DataFormat.JSON in story.flavors:
|
||||
self.json_writer.write(story)
|
||||
|
|
|
@ -28,7 +28,7 @@ import pytest
|
|||
|
||||
from fimfarchive.exceptions import InvalidStoryError, StorySourceError
|
||||
from fimfarchive.fetchers import Fetcher
|
||||
from fimfarchive.flavors import DataFormat, UpdateStatus
|
||||
from fimfarchive.flavors import DataFormat, StorySource, UpdateStatus
|
||||
from fimfarchive.selectors import RefetchSelector, UpdateSelector
|
||||
from fimfarchive.stories import Story
|
||||
from fimfarchive.tasks.update import (
|
||||
|
@ -261,6 +261,23 @@ class TestUpdateTask:
|
|||
"""
|
||||
self.verify_failure(task, fimfiction)
|
||||
|
||||
def test_write_meta(self, task, story):
|
||||
"""
|
||||
Tests writing of meta for stories from Fimfarchive.
|
||||
"""
|
||||
story = story.merge(flavors=[
|
||||
DataFormat.JSON,
|
||||
StorySource.FIMFARCHIVE,
|
||||
])
|
||||
|
||||
task.meta_writer.write = MagicMock()
|
||||
task.json_writer.write = MagicMock()
|
||||
|
||||
task.write(story)
|
||||
|
||||
task.meta_writer.write.assert_called_once_with(story)
|
||||
task.json_writer.write.assert_not_called()
|
||||
|
||||
def test_write_epub(self, task, story):
|
||||
"""
|
||||
Tests writing of a story in EPUB format.
|
||||
|
|
Loading…
Reference in a new issue