[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
|
import httpx
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from tests import factories
|
from tests import factories
|
||||||
|
from tests.utils import build_remote_actor
|
||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
@ -25,14 +26,8 @@ def test_inbox_follow_request(
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
# build test actor
|
# build test actor
|
||||||
ra = factories.RemoteActorFactory(
|
ra = build_remote_actor()
|
||||||
base_url="https://example.com",
|
|
||||||
username="test",
|
|
||||||
public_key="pk",
|
|
||||||
)
|
|
||||||
|
|
||||||
ap_id = ra.ap_id # type: ignore
|
ap_id = ra.ap_id # type: ignore
|
||||||
app.dependency_overrides[precheck.inbox_prechecker] = factories.inbox_prechecker
|
|
||||||
|
|
||||||
# mock request
|
# mock request
|
||||||
respx_mock.get(ap_id).mock(return_value=httpx.Response(200,json=ra.ap_actor))
|
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:
|
) -> None:
|
||||||
|
|
||||||
# build test actor
|
# build test actor
|
||||||
ra = factories.RemoteActorFactory(
|
ra = build_remote_actor()
|
||||||
base_url="https://example.com",
|
|
||||||
username="test",
|
|
||||||
public_key="pk",
|
|
||||||
)
|
|
||||||
|
|
||||||
ap_id = ra.ap_id # type: ignore
|
ap_id = ra.ap_id # type: ignore
|
||||||
app.dependency_overrides[precheck.inbox_prechecker] = factories.inbox_prechecker
|
app.dependency_overrides[precheck.inbox_prechecker] = factories.inbox_prechecker
|
||||||
|
|
|
@ -5,6 +5,7 @@ import respx
|
||||||
import httpx
|
import httpx
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from tests import factories
|
from tests import factories
|
||||||
|
from tests.utils import build_remote_actor
|
||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
@ -24,15 +25,8 @@ async def test_outbox_send_follow_request(
|
||||||
respx_mock: respx.MockRouter,
|
respx_mock: respx.MockRouter,
|
||||||
) -> None:
|
) -> None:
|
||||||
# build test actor
|
# build test actor
|
||||||
ra = factories.RemoteActorFactory(
|
ra = build_remote_actor()
|
||||||
base_url="https://example.com",
|
|
||||||
username="test",
|
|
||||||
public_key="pk",
|
|
||||||
)
|
|
||||||
|
|
||||||
remote_ap_id = ra.ap_id # type: ignore
|
remote_ap_id = ra.ap_id # type: ignore
|
||||||
app.dependency_overrides[precheck.inbox_prechecker] = \
|
|
||||||
factories.inbox_prechecker
|
|
||||||
|
|
||||||
# mock request
|
# mock request
|
||||||
respx_mock.get(remote_ap_id).mock(
|
respx_mock.get(remote_ap_id).mock(
|
||||||
|
@ -59,15 +53,8 @@ async def test_outbox_send_create_activity(
|
||||||
respx_mock: respx.MockRouter,
|
respx_mock: respx.MockRouter,
|
||||||
) -> None:
|
) -> None:
|
||||||
# build test actor
|
# build test actor
|
||||||
ra = factories.RemoteActorFactory(
|
ra = build_remote_actor()
|
||||||
base_url="https://example.com",
|
|
||||||
username="test",
|
|
||||||
public_key="pk",
|
|
||||||
)
|
|
||||||
|
|
||||||
remote_ap_id = ra.ap_id # type: ignore
|
remote_ap_id = ra.ap_id # type: ignore
|
||||||
app.dependency_overrides[precheck.inbox_prechecker] = \
|
|
||||||
factories.inbox_prechecker
|
|
||||||
|
|
||||||
# mock request
|
# mock request
|
||||||
respx_mock.get(remote_ap_id).mock(
|
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