[tests] add some comments in test inbox
This commit is contained in:
parent
25c9e1ef11
commit
97e5d98802
1 changed files with 11 additions and 6 deletions
|
@ -29,6 +29,7 @@ def test_inbox_follow_request(
|
||||||
) -> bool:
|
) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# build test actor
|
||||||
ra = factories.RemoteActorFactory(
|
ra = factories.RemoteActorFactory(
|
||||||
base_url="https://example.com",
|
base_url="https://example.com",
|
||||||
username="test",
|
username="test",
|
||||||
|
@ -36,11 +37,13 @@ def test_inbox_follow_request(
|
||||||
)
|
)
|
||||||
|
|
||||||
ap_id = ra.ap_id # type: ignore
|
ap_id = ra.ap_id # type: ignore
|
||||||
|
app.dependency_overrides[precheck.inbox_prechecker] = inbox_prechecker
|
||||||
|
|
||||||
|
# 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))
|
||||||
respx_mock.post(ap_id + "/inbox").mock(return_value=httpx.Response(202))
|
respx_mock.post(ap_id + "/inbox").mock(return_value=httpx.Response(202))
|
||||||
|
|
||||||
app.dependency_overrides[precheck.inbox_prechecker] = inbox_prechecker
|
# send follower request
|
||||||
|
|
||||||
with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False):
|
with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/inbox",
|
"/inbox",
|
||||||
|
@ -53,14 +56,16 @@ def test_inbox_follow_request(
|
||||||
"object": ap.ME["id"],
|
"object": ap.ME["id"],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 202
|
assert response.status_code == 202
|
||||||
|
|
||||||
|
# actor was saved in actor table
|
||||||
saved_actor = db.execute(select(models.Actor)).scalar_one()
|
saved_actor = db.execute(select(models.Actor)).scalar_one()
|
||||||
assert saved_actor.ap_id == ap_id
|
assert saved_actor.ap_id == ap_id
|
||||||
|
|
||||||
follower_actor = db.execute(select(models.Follower)).scalar_one()
|
# follower request was saved in outbox table
|
||||||
assert follower_actor.ap_actor_id == ap_id
|
|
||||||
|
|
||||||
outbox_object = db.execute(select(models.OutboxObject)).scalar_one()
|
outbox_object = db.execute(select(models.OutboxObject)).scalar_one()
|
||||||
assert outbox_object.ap_type == "Accept"
|
assert outbox_object.ap_type == "Accept"
|
||||||
|
|
||||||
|
# follower was saved in follower table
|
||||||
|
follower_actor = db.execute(select(models.Follower)).scalar_one()
|
||||||
|
assert follower_actor.ap_actor_id == ap_id
|
||||||
|
|
Loading…
Reference in a new issue