kopia lustrzana https://github.com/tsileo/little-boxes
Tweak the tests
rodzic
f2fa730da7
commit
af47e1d603
|
@ -192,6 +192,7 @@ class BaseBackend(object):
|
|||
id=f"https://lol.com/{pusername}",
|
||||
inbox=f"https://lol.com/{pusername}/inbox",
|
||||
followers=f"https://lol.com/{pusername}/followers",
|
||||
following=f"https://lol.com/{pusername}/following",
|
||||
)
|
||||
|
||||
self.USERS[p.preferredUsername] = p
|
||||
|
@ -213,6 +214,14 @@ class BaseBackend(object):
|
|||
"totalItems": len(data),
|
||||
"orderedItems": data,
|
||||
}
|
||||
if iri.endswith("/following"):
|
||||
data = self.FOLLOWING[iri.replace("/following", "")]
|
||||
return {
|
||||
"id": iri,
|
||||
"type": ActivityType.ORDERED_COLLECTION.value,
|
||||
"totalItems": len(data),
|
||||
"orderedItems": data,
|
||||
}
|
||||
return self.FETCH_MOCK[iri]
|
||||
|
||||
def get_user(self, username: str) -> "Person":
|
||||
|
|
|
@ -255,7 +255,7 @@ def test_little_boxes_follow_and_new_note_to_single_actor():
|
|||
)
|
||||
|
||||
|
||||
def test_little_boxes_follow_and_new_note_to_followers():
|
||||
def test_little_boxes_follow_and_new_note_to_followers_only():
|
||||
back, f = test_little_boxes_follow()
|
||||
|
||||
me = back.get_user("tom")
|
||||
|
@ -263,8 +263,68 @@ def test_little_boxes_follow_and_new_note_to_followers():
|
|||
|
||||
outbox = ap.Outbox(me)
|
||||
|
||||
# FIXME(tsileo): reverse the follow and actually use the follower call (right now, `me` has no followers)
|
||||
note = ap.Note(
|
||||
to=[me.followers], cc=[other.id], attributedTo=me.id, content="Hello"
|
||||
to=[ap.AS_PUBLIC], cc=[me.following], attributedTo=me.id, content="Hello"
|
||||
)
|
||||
outbox.post(note)
|
||||
|
||||
back.assert_called_methods(
|
||||
me,
|
||||
(
|
||||
"an Create activity is published",
|
||||
"outbox_new",
|
||||
lambda as_actor: _assert_eq(as_actor.id, me.id),
|
||||
lambda activity: _assert_eq(activity.get_object().id, note.id),
|
||||
),
|
||||
(
|
||||
'"outbox_create" hook is called',
|
||||
"outbox_create",
|
||||
lambda as_actor: _assert_eq(as_actor.id, me.id),
|
||||
lambda create: _assert_eq(create.get_object().id, note.id),
|
||||
),
|
||||
(
|
||||
"the Undo activity is posted to the followee",
|
||||
"post_to_remote_inbox",
|
||||
lambda as_actor: _assert_eq(as_actor.id, me.id),
|
||||
lambda payload: None,
|
||||
lambda recipient: _assert_eq(recipient, other.inbox),
|
||||
),
|
||||
)
|
||||
|
||||
back.assert_called_methods(
|
||||
other,
|
||||
(
|
||||
"receiving the Undo, ensure we check the actor is not blocked",
|
||||
"outbox_is_blocked",
|
||||
lambda as_actor: _assert_eq(as_actor.id, other.id),
|
||||
lambda remote_actor: _assert_eq(remote_actor, me.id),
|
||||
),
|
||||
(
|
||||
"receiving the Create activity",
|
||||
"inbox_new",
|
||||
lambda as_actor: _assert_eq(as_actor.id, other.id),
|
||||
lambda activity: _assert_eq(activity.get_object().id, note.id),
|
||||
),
|
||||
(
|
||||
'"inbox_create" hook is called',
|
||||
"inbox_create",
|
||||
lambda as_actor: _assert_eq(as_actor.id, other.id),
|
||||
lambda create: _assert_eq(create.get_object().id, note.id),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def test_little_boxes_follow_and_new_note_to_followers_and_single_actor_dedup():
|
||||
back, f = test_little_boxes_follow()
|
||||
|
||||
me = back.get_user("tom")
|
||||
other = back.get_user("tom2")
|
||||
|
||||
outbox = ap.Outbox(me)
|
||||
|
||||
note = ap.Note(
|
||||
to=[ap.AS_PUBLIC], cc=[other.id, me.followers], attributedTo=me.id, content="Hello"
|
||||
)
|
||||
outbox.post(note)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue