Spaces:
Running
Running
File size: 1,048 Bytes
7936dbe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """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
|