mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-22 05:17:59 +01:00
Return Arrow object from story date mapper
This commit is contained in:
parent
ef0e7a9570
commit
b6718b96aa
3 changed files with 12 additions and 9 deletions
|
@ -24,6 +24,8 @@ Mappers for Fimfarchive.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import arrow
|
||||||
|
|
||||||
from fimfarchive.exceptions import InvalidStoryError
|
from fimfarchive.exceptions import InvalidStoryError
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ class StoryDateMapper(Mapper):
|
||||||
dates.discard(None)
|
dates.discard(None)
|
||||||
|
|
||||||
if dates:
|
if dates:
|
||||||
return max(dates)
|
return max(arrow.get(date) for date in dates)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
arrow
|
||||||
blinker
|
blinker
|
||||||
jmespath
|
jmespath
|
||||||
requests
|
requests
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_none_chapters(self, mapper, story):
|
def test_meta_with_none_chapters(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -164,7 +164,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_empty_chapters(self, mapper, story):
|
def test_meta_with_empty_chapters(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -177,7 +177,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_only_chapter_dates(self, mapper, story):
|
def test_meta_with_only_chapter_dates(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -193,7 +193,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_only_story_date(self, mapper, story):
|
def test_meta_with_only_story_date(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -210,7 +210,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_latest_chapter_date(self, mapper, story):
|
def test_meta_with_latest_chapter_date(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -227,7 +227,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_latest_story_date(self, mapper, story):
|
def test_meta_with_latest_story_date(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -244,7 +244,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
def test_meta_with_both_latest(self, mapper, story):
|
def test_meta_with_both_latest(self, mapper, story):
|
||||||
"""
|
"""
|
||||||
|
@ -261,7 +261,7 @@ class TestStoryDateMapper:
|
||||||
|
|
||||||
story = story.merge(meta=meta)
|
story = story.merge(meta=meta)
|
||||||
|
|
||||||
assert mapper(story) == 5
|
assert mapper(story).timestamp == 5
|
||||||
|
|
||||||
|
|
||||||
class TestStoryPathMapper:
|
class TestStoryPathMapper:
|
||||||
|
|
Loading…
Reference in a new issue