Skip to content

Commit

Permalink
Fix #2534 and #2535 Test in wikipedia and arxiv
Browse files Browse the repository at this point in the history
Doctest in arxiv.py failed because of change in error message from the arxiv
server. A more general test is now done in the doctest which is not dependent
on the specicific error message.

A doctest in wikipedia.py failed because the default requests user agent was
banned by the Wikidata Query Service. Now the user agent is set based on the
Scholia configuration.
  • Loading branch information
fnielsen committed Sep 10, 2024
1 parent c2b6297 commit 2f85cb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scholia/arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def get_metadata(arxiv):
>>> metadata = get_metadata('1503.00759')
>>> metadata['doi'] == '10.1109/JPROC.2015.2483592'
True
>>> get_metadata('5432.01234')
{'error': 'Not found'}
>>> 'error' in get_metadata('5432.01234')
True
"""
arxiv = arxiv.strip()
Expand Down
3 changes: 2 additions & 1 deletion scholia/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def q_to_bibliography_templates(q):
query = BIBLIOGRAPHY_SPARQL_QUERY.format(q=q)
url = SPARQL_ENDPOINT
params = {'query': query, 'format': 'json'}
response = requests.get(url, params=params)
headers = {'User-Agent': config['requests'].get('user_agent')}
response = requests.get(url, params=params, headers=headers)
data = response.json()

wikitext = ('<!-- Generated with scholia.wikipedia '
Expand Down

0 comments on commit 2f85cb2

Please sign in to comment.