diff --git a/tests/test_inbox.py b/tests/test_inbox.py index c806271..3db3d6f 100644 --- a/tests/test_inbox.py +++ b/tests/test_inbox.py @@ -40,13 +40,14 @@ def test_inbox_follow_request( # send follower request with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False): + follow_id = ap_id + "/follow/" + (uuid4().hex) response = client.post( "/inbox", headers={"Content-Type": AP_CONTENT_TYPE}, json={ "@context": ap.AS_CTX, "type": "Follow", - "id": ap_id + "/follow/" + (uuid4().hex), + "id": follow_id, "actor": ap_id, "object": ap.ME["id"], }, @@ -65,6 +66,31 @@ def test_inbox_follow_request( follower_actor = db.execute(select(models.Follower)).scalar_one() assert follower_actor.ap_actor_id == ap_id + # send undo follower request + with mock.patch("app.boxes.MANUALLY_APPROVES_FOLLOWERS", False): + undo_id = ap_id + "/undo/" + (uuid4().hex) + response = client.post( + "/inbox", + headers={"Content-Type": AP_CONTENT_TYPE}, + json={ + "@context": ap.AS_CTX, + "type": "Undo", + "id": undo_id, + "actor": ap_id, + "object": { + "type": "Follow", + "id": follow_id, + "actor": ap_id, + "object": ap.ME["id"], + }, + }, + ) + assert response.status_code == 202 + + # follower was not saved in follower table + follower_actor = db.execute(select(models.Follower)).scalar_one_or_none() + assert follower_actor == None + def test_inbox_announce_request( db: Session,