From 9ff2d04ccf4a49a3735531ac6c811d7f36021d47 Mon Sep 17 00:00:00 2001 From: southfox Date: Tue, 11 Apr 2023 16:07:35 +0800 Subject: [PATCH] [refactor] test inbox prechecker --- tests/factories.py | 8 ++++++++ tests/test_inbox.py | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/factories.py b/tests/factories.py index aacae64..17b5e36 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -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 diff --git a/tests/test_inbox.py b/tests/test_inbox.py index ffe18f6..648cc3c 100644 --- a/tests/test_inbox.py +++ b/tests/test_inbox.py @@ -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))