[test] add follow in/outbox object tests
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
SouthFox 2023-08-03 20:59:58 +08:00
parent 1ce90a297a
commit a1f801c1d2
2 changed files with 12 additions and 1 deletions

View file

@ -52,13 +52,18 @@ def test_inbox_follow_request(
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 request was saved in outbox table # follow request was saved in inbox table
inbox_object = db.execute(select(models.InboxObject)).scalar_one()
assert inbox_object.ap_type == "Follow"
# follow accept response was saved in outbox table
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 was saved in follower table
follower_actor = db.execute(select(models.Follower)).scalar_one() follower_actor = db.execute(select(models.Follower)).scalar_one()
assert follower_actor.ap_actor_id == ap_id assert follower_actor.ap_actor_id == ap_id
assert follower_actor.inbox_object == inbox_object
# send undo follower request # send undo follower request
with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False): with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False):

View file

@ -62,6 +62,12 @@ async def test_outbox_send_follow_request(
# follower was saved in follower table # follower was saved in follower table
following_actor = db.execute(select(models.Following)).scalar_one() following_actor = db.execute(select(models.Following)).scalar_one()
assert following_actor.ap_actor_id == remote_ap_id assert following_actor.ap_actor_id == remote_ap_id
assert following_actor.outbox_object == outbox_object
inbox_object = db.execute(select(models.InboxObject)).scalar_one()
assert inbox_object.ap_type == "Accept"
@pytest.mark.asyncio @pytest.mark.asyncio