Spaces:
Running
Running
Download tests/test_trusted_links_api.py from nikeshn/researchbee: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/nikeshn/researchbee/resolve/main/tests/test_trusted_links_api.py
- Command line
-
hf download hf://spaces/nikeshn/researchbee/tests/test_trusted_links_api.py
-
curl -L -o test_trusted_links_api.py https://huggingface.co/spaces/nikeshn/researchbee/resolve/main/tests/test_trusted_links_api.py
1.05 kB
| """Framework integration tests, executed by the Docker pytest build gate.""" | |
| from fastapi.testclient import TestClient | |
| import app | |
| def test_discovery_endpoint_accepts_identity_only(monkeypatch): | |
| captured=[] | |
| async def fake_discover(value): | |
| captured.append(value) | |
| return {'homepage':{'url':None},'guidelines':{'url':None,'status':'unavailable'}} | |
| monkeypatch.setattr(app,'discover',fake_discover) | |
| monkeypatch.setattr(app,'check_rate_limit',lambda *args:True) | |
| response=TestClient(app.app).post('/api/journal-links',json={ | |
| 'scopus_id':'21206','url':'https://127.0.0.1/private'}) | |
| assert response.status_code==200 | |
| assert captured==[{'scopus_id':'21206','issn':''}] | |
| assert response.json()['guidelines']['status']=='unavailable' | |
| def test_discovery_endpoint_rate_limited(monkeypatch): | |
| monkeypatch.setattr(app,'check_rate_limit',lambda *args:False) | |
| response=TestClient(app.app).post('/api/journal-links',json={'scopus_id':'21206'}) | |
| assert response.status_code==429 | |