[tests] add inbox stub test

This commit is contained in:
SouthFox 2023-04-06 17:36:10 +08:00
parent 5c01f24e91
commit bf8142eb0b

35
tests/test_inbox.py Normal file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env python3
import pytest
import fastapi
import respx
from app.main import app
from app.utils import precheck
from fastapi.testclient import TestClient
from sqlalchemy.orm import Session
from app import activitypub as ap, httpsig
from app.config import AP_CONTENT_TYPE
def test_inbox_announce_request(
db: Session,
client: TestClient,
respx_mock: respx.MockRouter,
) -> None:
async def inbox_prechecker(
request: fastapi.Request,
) -> bool:
return True
app.dependency_overrides[precheck.inbox_prechecker] = inbox_prechecker
response = client.post(
"/inbox",
headers={"Content-Type": AP_CONTENT_TYPE},
json={"stub": 1},
)
print(response.headers)
print(response.content)
assert response.status_code == 200