Uses get_data helper in isbn search (plus test)

This commit is contained in:
Mouse Reeve
2021-03-13 09:07:19 -08:00
parent e459c440de
commit d3b1941eaa
2 changed files with 17 additions and 15 deletions

View File

@ -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