[books] Fix dead source icon links and gate ComicVine lookups
This commit is contained in:
84
tests/books_tests/test_book_source_links.py
Normal file
84
tests/books_tests/test_book_source_links.py
Normal file
@ -0,0 +1,84 @@
|
||||
import pytest
|
||||
from books.models import Book
|
||||
from django.test import override_settings
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_openlibrary_link_work_id():
|
||||
book = Book.objects.create(title="Test Book", openlibrary_id="OL1234567W")
|
||||
assert book.openlibrary_link == "https://openlibrary.org/works/OL1234567W"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_openlibrary_link_edition_id():
|
||||
book = Book.objects.create(title="Test Book", openlibrary_id="OL1234567M")
|
||||
assert book.openlibrary_link == "https://openlibrary.org/books/OL1234567M"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_openlibrary_link_empty():
|
||||
book = Book.objects.create(title="Test Book")
|
||||
assert book.openlibrary_link == ""
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_bookshop_link_isbn_13_without_affiliate():
|
||||
book = Book.objects.create(title="Test Book", isbn_13="9783161484100")
|
||||
assert book.bookshop_link == "https://bookshop.org/books?keywords=9783161484100"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_bookshop_link_isbn_10_without_affiliate():
|
||||
book = Book.objects.create(title="Test Book", isbn_10="0805061762")
|
||||
assert book.bookshop_link == "https://bookshop.org/books?keywords=0805061762"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@override_settings(BOOKSHOP_AFFILIATE_ID="abc123")
|
||||
def test_bookshop_link_with_affiliate():
|
||||
book = Book.objects.create(title="Test Book", isbn_13="9783161484100")
|
||||
assert book.bookshop_link == "https://bookshop.org/a/abc123/9783161484100"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_bookshop_link_empty():
|
||||
book = Book.objects.create(title="Test Book")
|
||||
assert book.bookshop_link == ""
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_false_for_prose_book():
|
||||
book = Book.objects.create(title="A Gentle Madness")
|
||||
assert book.is_comic is False
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_true_for_comicvine_id():
|
||||
book = Book.objects.create(title="Spider-Man", comicvine_id="538480")
|
||||
assert book.is_comic is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_true_for_readcomics_url():
|
||||
book = Book.objects.create(
|
||||
title="Saga", readcomics_url="https://readcomicsonline.ru/comic/saga/1"
|
||||
)
|
||||
assert book.is_comic is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_true_for_issue_number():
|
||||
book = Book.objects.create(title="Watchmen", issue_number=1)
|
||||
assert book.is_comic is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_true_for_issue_in_title():
|
||||
book = Book.objects.create(title="Star Wars Issue 42")
|
||||
assert book.is_comic is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_is_comic_true_for_volume_in_title():
|
||||
book = Book.objects.create(title="East of West Volume 2")
|
||||
assert book.is_comic is True
|
||||
Reference in New Issue
Block a user