convert between ibsn 10 and 13

This commit is contained in:
Mouse Reeve
2020-10-29 12:32:37 -07:00
parent 90cccc455e
commit 7febcec229
7 changed files with 97 additions and 24 deletions

View File

@ -34,16 +34,6 @@ class BookWyrmConnector(TestCase):
self.assertEqual(self.connector.is_work_data(self.edition_data), False)
def test_get_edition_from_work_data(self):
edition = self.connector.get_edition_from_work_data(self.work_data)
self.assertEqual(edition['url'], 'https://example.com/book/122')
def test_get_work_from_edition_data(self):
work = self.connector.get_work_from_edition_date(self.edition_data)
self.assertEqual(work['url'], 'https://example.com/book/121')
def test_format_search_result(self):
datafile = pathlib.Path(__file__).parent.joinpath('../data/fr_search.json')
search_data = json.loads(datafile.read_bytes())

View File

@ -2,6 +2,7 @@
from django.test import TestCase
from bookwyrm import models, settings
from bookwyrm.models.book import isbn_10_to_13, isbn_13_to_10
class Book(TestCase):
@ -48,6 +49,16 @@ class Book(TestCase):
self.assertEqual(self.work.default_edition, self.second_edition)
def test_isbn_10_to_13(self):
isbn_10 = '178816167X'
isbn_13 = isbn_10_to_13(isbn_10)
self.assertEqual(isbn_13, '9781788161671')
def test_isbn_13_to_10(self):
isbn_13 = '9781788161671'
isbn_10 = isbn_13_to_10(isbn_13)
self.assertEqual(isbn_10, '178816167X')
class Shelf(TestCase):
def setUp(self):