Return Arrow object from story date mapper

This commit is contained in:
Joakim Soderlund 2017-10-25 22:08:24 +02:00
parent ef0e7a9570
commit b6718b96aa
3 changed files with 12 additions and 9 deletions

View file

@ -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

View file

@ -1,3 +1,4 @@
arrow
blinker blinker
jmespath jmespath
requests requests

View file

@ -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: