Commit 1153a5c1 authored by Patrick van der Leer's avatar Patrick van der Leer
Browse files

crap for tomorrow, stupid api quota/limit

parent 94a182a8
Pipeline #318 failed with stage
in 2 minutes and 42 seconds
from collections import OrderedDict
import json
from googleapiclient.discovery import build, Resource
from googleapiclient.http import HttpMockSequence
from eBookHub import cache
from eBookHub.parser.exceptions import NoResultsException
......@@ -14,7 +15,27 @@ class GoogleBooksClient(SourceAbstract):
def init_app(self, app=None):
super().init_app(app)
self.client = build('books', 'v1', developerKey=app.config.get("GOOGLE_BOOKS_DEV_KEY"))
if app.testing:
resp_raw = json.dumps({
"kind": "books#volumes",
"totalItems": 0,
})
http = HttpMockSequence([({'status': '200'}, resp_raw) for _ in range(10)])
self.client = build(
'books',
'v1',
http=http,
developerKey=app.config.get("GOOGLE_BOOKS_DEV_KEY")
)
else:
import httplib2
httplib2.Http(cache=".cache")
self.client = build(
'books',
'v1',
http=httplib2.Http(cache=".cache"),
developerKey=app.config.get("GOOGLE_BOOKS_DEV_KEY")
)
assert isinstance(self.client, Resource)
@cache.memoize()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment