Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_web_query_fails_with_multiple_results():
url = 'https://www.ncbi.nlm.nih.gov/pubmed/?term=sci-hub%5Btitle%5D'
with pytest.raises(ValueError, match='multiple results'):
web_query(url)
def test_web_query():
"""
The translation-server web endpoint can be tested via curl:
```
curl \
--header "Content-Type: text/plain" \
--data 'https://bigthink.com/neurobonkers/a-pirate-bay-for-science' \
'https://translate.manubot.org/web'
```
"""
url = 'https://bigthink.com/neurobonkers/a-pirate-bay-for-science'
zotero_data = web_query(url)
assert isinstance(zotero_data, list)
assert len(zotero_data) == 1
assert zotero_data[0]['title'] == "Meet the Robin Hood of Science"
def get_url_csl_item_zotero(url):
"""
Use Zotero's translation-server to generate a CSL Item for the specified URL.
"""
from manubot.cite.zotero import export_as_csl, web_query
zotero_data = web_query(url)
csl_data = export_as_csl(zotero_data)
(csl_item,) = csl_data
return csl_item