Exemplo n.º 1
0
    def test_cover_url_from_googlebooks(self, mock_get):
        """Tests if method gets a Cover url for ISBN."""

        response = gbooks_covers.find_cover_url_by_isbn(self.ISBN_for_cover)
        expected = "http://books.google.es/books/content?id=CoBGdI5WyOIC&printsec=frontcover&" \
                   "img=1&zoom=1&edge=curl&source=gbs_api"

        self.assertEqual(response, expected)
        self.assertTrue(mock_get.called)
Exemplo n.º 2
0
def isbn(request, value):
    """View to render the information about a single book details, including its cover if it is available.
    Books could be found by ISBN or internal book_id according to ISBNdb API.

    :param request: The http request
    :return: a render of the given HTML page.
    """
    # filtering by "book" includes ISBN direct search and title direct search
    response = isbn_utils.search_by("book", value)
    isbn13 = response.data[0]["isbn13"]
    cover_url = gbooks_covers.find_cover_url_by_isbn(isbn13)
    context = {
        'book_details': response.data,
        'cover_url': cover_url,
    }

    return render(request, 'taric_books/isbn.html', context)
Exemplo n.º 3
0
    def test_cover_url_from_googlebooks_no_book(self, mock_get):
        """Tests if method returns None if there is no book found in GoogleBooks with provided ISBN."""

        response = gbooks_covers.find_cover_url_by_isbn(self.ISBN_no_book_cover)
        self.assertIsNone(response)
        self.assertTrue(mock_get.called)