Merge branch 'master' of github.com:Gluejar/regluit
commit
a9675bdd10
|
@ -107,7 +107,7 @@ def get_google_isbn_results(isbn):
|
|||
def add_ebooks(item, edition):
|
||||
access_info = item.get('accessInfo')
|
||||
if access_info:
|
||||
edition.public_domain = item.get('public_domain', None)
|
||||
edition.public_domain = access_info.get('publicDomain', None)
|
||||
epub = access_info.get('epub')
|
||||
if epub and epub.get('downloadLink'):
|
||||
ebook = models.Ebook(edition=edition, format='epub',
|
||||
|
|
|
@ -23,6 +23,7 @@ from celery.task import chord
|
|||
|
||||
from time import sleep
|
||||
from math import factorial
|
||||
from urlparse import parse_qs, urlparse
|
||||
|
||||
|
||||
class BookLoaderTests(TestCase):
|
||||
|
@ -54,7 +55,7 @@ class BookLoaderTests(TestCase):
|
|||
e = models.Edition(title=w.title,work=w)
|
||||
e.save()
|
||||
models.Identifier(type='isbn', value='9780226032030', work=w, edition=e).save()
|
||||
bookloader.update_edition(e)
|
||||
bookloader.update_edition(e)
|
||||
self.assertEqual(e.work.language, 'en')
|
||||
self.assertEqual(e.title, 'Forbidden journeys')
|
||||
|
||||
|
@ -223,18 +224,23 @@ class BookLoaderTests(TestCase):
|
|||
#ebook_epub = edition.ebooks.all()[0]
|
||||
ebook_epub = edition.ebooks.filter(format='epub')[0]
|
||||
self.assertEqual(ebook_epub.format, 'epub')
|
||||
self.assertEqual(ebook_epub.url, 'http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api')
|
||||
#self.assertEqual(ebook_epub.url, 'http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api')
|
||||
self.assertEqual(parse_qs(urlparse(ebook_epub.url).query).get("id"), ['U3FXAAAAYAAJ'])
|
||||
self.assertEqual(parse_qs(urlparse(ebook_epub.url).query).get("output"), ['epub'])
|
||||
self.assertEqual(ebook_epub.provider, 'google')
|
||||
ebook_pdf = edition.ebooks.filter(format='pdf')[0]
|
||||
self.assertEqual(ebook_pdf.format, 'pdf')
|
||||
self.assertEqual(ebook_pdf.url, 'http://books.google.com/books/download/The_Latin_language.pdf?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=pdf&sig=ACfU3U2yLt3nmTncB8ozxOWUc4iHKUznCA&source=gbs_api')
|
||||
#self.assertEqual(ebook_pdf.url, 'http://books.google.com/books/download/The_Latin_language.pdf?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=pdf&sig=ACfU3U2yLt3nmTncB8ozxOWUc4iHKUznCA&source=gbs_api')
|
||||
self.assertEqual(parse_qs(urlparse(ebook_pdf.url).query).get("id"), ['U3FXAAAAYAAJ'])
|
||||
self.assertEqual(parse_qs(urlparse(ebook_pdf.url).query).get("output"), ['pdf'])
|
||||
self.assertEqual(ebook_pdf.provider, 'google')
|
||||
self.assertEqual(edition.public_domain, True)
|
||||
|
||||
w = edition.work
|
||||
self.assertEqual(w.first_epub().url, "http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api")
|
||||
self.assertEqual(w.first_pdf().url, "http://books.google.com/books/download/The_Latin_language.pdf?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=pdf&sig=ACfU3U2yLt3nmTncB8ozxOWUc4iHKUznCA&source=gbs_api")
|
||||
self.assertEqual(w.first_epub_url(), "http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api")
|
||||
self.assertEqual(w.first_pdf_url(), "http://books.google.com/books/download/The_Latin_language.pdf?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=pdf&sig=ACfU3U2yLt3nmTncB8ozxOWUc4iHKUznCA&source=gbs_api")
|
||||
self.assertEqual(w.first_epub().url, ebook_epub.url)
|
||||
self.assertEqual(w.first_pdf().url, ebook_pdf.url)
|
||||
self.assertEqual(w.first_epub_url(), ebook_epub.url)
|
||||
self.assertEqual(w.first_pdf_url(), ebook_pdf.url)
|
||||
|
||||
def test_add_no_ebook(self):
|
||||
# this edition lacks an ebook, but we should still be able to load it
|
||||
|
|
Loading…
Reference in New Issue