Skip to content

Commit

Permalink
Merge pull request #13 from golnazads/master
Browse files Browse the repository at this point in the history
gunicorn does not like backslash in doi
  • Loading branch information
golnazads committed Apr 16, 2018
2 parents 1240c92 + 4e10146 commit 651cbac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions resolverway/tests/unittests/test_resolver_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ def test_multiple_links(self):
self.assertEqual(r[0], data.html_data)
self.assertEqual(r[1], 200)

def test_identification_link(self):
"""
Tests single link response for identification link types
:return:
"""
the_json = {"action": "redirect",
"link": "http://dx.doi.org/10.1088/2041-8205/713/2/L10",
"service": "https://ui.adsabs.harvard.edu/#abs/2010ApJ...713L.103B/DOI:10.1088/2041-8205/713/2/L103"}
r = LinkRequest('2010ApJ...713L.103B', 'DOI', '10.1088_2041-8205_713_2_L10').process_resolver_response(the_json)
self.assertEqual(r[1], 302)

the_json = {"action": "redirect",
"link": "http://arxiv.org/abs/1803.03598",
"service": "https://ui.adsabs.harvard.edu/#abs/2018arXiv180303598K/ARXIV:1803.03598"}
r = LinkRequest('2018arXiv180303598K', 'ARXIV', '1803.03598').process_resolver_response(the_json)
self.assertEqual(r[1], 302)

def test_action_error(self):
"""
Test if unrecognizable action is returned
Expand Down
3 changes: 3 additions & 0 deletions resolverway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def resolver_id(bibcode, link_type, id):
:param id:
:return:
"""
# gunicorn does not like / so it is passed as underscore and returned back to / here
if link_type.lower() == 'doi':
id = id.replace('_', '/')
return LinkRequest(bibcode, link_type.upper(), id=id).process_request()


0 comments on commit 651cbac

Please sign in to comment.