From bf8142eb0b4c41cf3860aae2e8279bceaff4c9b8 Mon Sep 17 00:00:00 2001 From: southfox Date: Thu, 6 Apr 2023 17:36:10 +0800 Subject: [PATCH] [tests] add inbox stub test --- tests/test_inbox.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_inbox.py diff --git a/tests/test_inbox.py b/tests/test_inbox.py new file mode 100644 index 0000000..6a7fca5 --- /dev/null +++ b/tests/test_inbox.py @@ -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