[tests] add undo test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
SouthFox 2023-04-27 11:18:03 +08:00
parent 4e6e9d803e
commit c21a792b2b

View file

@ -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,