Uses get_data helper in isbn search (plus test)
This commit is contained in:
@ -57,24 +57,14 @@ class AbstractMinimalConnector(ABC):
|
||||
def isbn_search(self, query):
|
||||
""" isbn search """
|
||||
params = {}
|
||||
resp = requests.get(
|
||||
data = get_data(
|
||||
"%s%s" % (self.isbn_search_url, query),
|
||||
params=params,
|
||||
headers={
|
||||
"Accept": "application/json; charset=utf-8",
|
||||
"User-Agent": settings.USER_AGENT,
|
||||
},
|
||||
)
|
||||
if not resp.ok:
|
||||
resp.raise_for_status()
|
||||
try:
|
||||
data = resp.json()
|
||||
except ValueError as e:
|
||||
logger.exception(e)
|
||||
raise ConnectorException("Unable to parse json response", e)
|
||||
results = []
|
||||
|
||||
for doc in self.parse_isbn_search_data(data):
|
||||
# this shouldn't be returning mutliple results, but just in case
|
||||
for doc in self.parse_isbn_search_data(data)[:10]:
|
||||
results.append(self.format_isbn_search_result(doc))
|
||||
return results
|
||||
|
||||
|
Reference in New Issue
Block a user