[refactor] test inbox prechecker
This commit is contained in:
parent
4b2c978794
commit
9ff2d04ccf
2 changed files with 10 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import factory
|
||||
import fastapi
|
||||
import app.activitypub as ap
|
||||
from app import models
|
||||
|
||||
|
@ -61,3 +62,10 @@ class ActorFactory(factory.alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
ap_type = "Person"
|
||||
ap_id = "stub"
|
||||
|
||||
|
||||
|
||||
async def inbox_prechecker(
|
||||
request: fastapi.Request,
|
||||
) -> bool:
|
||||
return True
|
||||
|
|
|
@ -4,7 +4,7 @@ import fastapi
|
|||
import respx
|
||||
import httpx
|
||||
from uuid import uuid4
|
||||
from tests import factories # type: ignore
|
||||
from tests import factories
|
||||
|
||||
from unittest import mock
|
||||
from app.main import app
|
||||
|
@ -24,11 +24,6 @@ def test_inbox_follow_request(
|
|||
respx_mock: respx.MockRouter,
|
||||
) -> None:
|
||||
|
||||
async def inbox_prechecker(
|
||||
request: fastapi.Request,
|
||||
) -> bool:
|
||||
return True
|
||||
|
||||
# build test actor
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
|
@ -37,7 +32,7 @@ def test_inbox_follow_request(
|
|||
)
|
||||
|
||||
ap_id = ra.ap_id # type: ignore
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = inbox_prechecker
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = factories.inbox_prechecker
|
||||
|
||||
# mock request
|
||||
respx_mock.get(ap_id).mock(return_value=httpx.Response(200,json=ra.ap_actor))
|
||||
|
|
Loading…
Reference in a new issue