fix: return the publisher an EPUB declares
The lookup discarded its own result and fell off the end of the function, so no EPUB ever contributed a publisher.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
from ebooklib import epub
|
||||
from pathlib import Path
|
||||
from datetime import date
|
||||
from chitai.services.metadata_extractor import (
|
||||
@@ -172,3 +173,20 @@ class TestEditionFromFiles:
|
||||
|
||||
assert metadata["title"] == "The Project Gutenberg eBook #33283: Calculus Made Easy"
|
||||
assert metadata["edition"] == 2
|
||||
|
||||
|
||||
class TestEpubPublisher:
|
||||
"""The publisher was looked up and then dropped on the floor."""
|
||||
|
||||
def test_a_declared_publisher_is_returned(self) -> None:
|
||||
"""
|
||||
The lookup discarded its own result and fell off the end of the function, so
|
||||
every EPUB reported no publisher no matter what it said.
|
||||
"""
|
||||
book = epub.EpubBook()
|
||||
book.add_metadata("DC", "publisher", "No Starch Press")
|
||||
|
||||
assert EpubExtractor._extract_publisher(book) == "No Starch Press"
|
||||
|
||||
def test_no_publisher_is_none(self) -> None:
|
||||
assert EpubExtractor._extract_publisher(epub.EpubBook()) is None
|
||||
|
||||
Reference in New Issue
Block a user