[refactor] build renote actor
This commit is contained in:
parent
7fbb4bbd81
commit
c37b0cddce
3 changed files with 24 additions and 28 deletions
|
@ -5,6 +5,7 @@ import respx
|
|||
import httpx
|
||||
from uuid import uuid4
|
||||
from tests import factories
|
||||
from tests.utils import build_remote_actor
|
||||
|
||||
from unittest import mock
|
||||
from app.main import app
|
||||
|
@ -25,14 +26,8 @@ def test_inbox_follow_request(
|
|||
) -> None:
|
||||
|
||||
# build test actor
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
username="test",
|
||||
public_key="pk",
|
||||
)
|
||||
|
||||
ra = build_remote_actor()
|
||||
ap_id = ra.ap_id # type: ignore
|
||||
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))
|
||||
|
@ -99,11 +94,7 @@ def test_inbox_announce_request(
|
|||
) -> None:
|
||||
|
||||
# build test actor
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
username="test",
|
||||
public_key="pk",
|
||||
)
|
||||
ra = build_remote_actor()
|
||||
|
||||
ap_id = ra.ap_id # type: ignore
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = factories.inbox_prechecker
|
||||
|
|
|
@ -5,6 +5,7 @@ import respx
|
|||
import httpx
|
||||
from uuid import uuid4
|
||||
from tests import factories
|
||||
from tests.utils import build_remote_actor
|
||||
|
||||
from unittest import mock
|
||||
from app.main import app
|
||||
|
@ -24,15 +25,8 @@ async def test_outbox_send_follow_request(
|
|||
respx_mock: respx.MockRouter,
|
||||
) -> None:
|
||||
# build test actor
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
username="test",
|
||||
public_key="pk",
|
||||
)
|
||||
|
||||
ra = build_remote_actor()
|
||||
remote_ap_id = ra.ap_id # type: ignore
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = \
|
||||
factories.inbox_prechecker
|
||||
|
||||
# mock request
|
||||
respx_mock.get(remote_ap_id).mock(
|
||||
|
@ -59,15 +53,8 @@ async def test_outbox_send_create_activity(
|
|||
respx_mock: respx.MockRouter,
|
||||
) -> None:
|
||||
# build test actor
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
username="test",
|
||||
public_key="pk",
|
||||
)
|
||||
|
||||
ra = build_remote_actor()
|
||||
remote_ap_id = ra.ap_id # type: ignore
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = \
|
||||
factories.inbox_prechecker
|
||||
|
||||
# mock request
|
||||
respx_mock.get(remote_ap_id).mock(
|
||||
|
|
18
tests/utils.py
Normal file
18
tests/utils.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
from tests import factories
|
||||
from app.main import app
|
||||
from app.utils import precheck
|
||||
|
||||
|
||||
|
||||
def build_remote_actor():
|
||||
ra = factories.RemoteActorFactory(
|
||||
base_url="https://example.com",
|
||||
username="test",
|
||||
public_key="pk",
|
||||
)
|
||||
|
||||
app.dependency_overrides[precheck.inbox_prechecker] = \
|
||||
factories.inbox_prechecker
|
||||
|
||||
return ra
|
Loading…
Reference in a new issue