researchbee / tests /test_trusted_links_api.py
nikeshn's picture
Upload 14 files
7936dbe verified
Raw History Blame Contribute Delete
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