Skip to content

Commit

Permalink
Merge 37c54c7 into 253e48f
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemansteve committed May 1, 2019
2 parents 253e48f + 37c54c7 commit 8f4d0cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion adsmp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,10 @@ def generate_links_for_resolver(self, record):
url = bib_links_data.get('url', None)
if url:
resolver_record = {'bibcode': bibcode,
'data_links_rows': [{'url': [url]}]}
'data_links_rows': [{'url': [url],
'title': '', 'count': 0,
'link_type': 'ESOURCE',
'link_sub_type': 'EPRINT_HTML'}]}
except (KeyError, ValueError):
# here if record holds unexpected value
self.logger.error('invalid value in bib data, bibcode = {}, type = {}, value = {}'.format(bibcode, type(bib_links_record), bib_links_record))
Expand Down
12 changes: 10 additions & 2 deletions adsmp/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,12 @@ def test_generate_links_for_resolver(self):
{'links_data': ['{"access": "open", "instances": "", "title": "", "type": "preprint", "url": "http://arxiv.org/abs/1902.09522"}']}}
links = self.app.generate_links_for_resolver(only_bib)
self.assertEqual(only_bib['bibcode'], links['bibcode'])
self.assertEqual('http://arxiv.org/abs/1902.09522', links['data_links_rows'][0]['url'][0])
first = links['data_links_rows'][0]
self.assertEqual('http://arxiv.org/abs/1902.09522', first['url'][0])
self.assertEqual('ESOURCE', first['link_type'])
self.assertEqual('EPRINT_HTML', first['link_sub_type'])
self.assertEqual('', first['title'])
self.assertEqual(0, first['count'])

bib_and_nonbib = {'bibcode': 'asdf',
'bib_data':
Expand All @@ -376,7 +381,10 @@ def test_generate_links_for_resolver(self):
{'links_data': [u'{"access": "open", "instances": "", "title": "", "type": "preprint", "url": "http://arxiv.org/abs/1902.09522"}']}}
links = self.app.generate_links_for_resolver(only_bib)
self.assertEqual(only_bib['bibcode'], links['bibcode'])
self.assertEqual('http://arxiv.org/abs/1902.09522', links['data_links_rows'][0]['url'][0])
first = links['data_links_rows'][0]
self.assertEqual('http://arxiv.org/abs/1902.09522', first['url'][0])
self.assertEqual('ESOURCE', first['link_type'])
self.assertEqual('EPRINT_HTML', first['link_sub_type'])

# bad string in database
with mock.patch.object(self.app.logger, 'error') as m:
Expand Down

0 comments on commit 8f4d0cf

Please sign in to comment.