def test_inbox_routing_send_to_channel(factories, mocker): group_send = mocker.patch("funkwhale_api.common.channels.group_send") a = factories["federation.Activity"](type="Follow") ii = factories["federation.InboxItem"](actor__local=True) router = activity.InboxRouter() handler = mocker.stub() router.connect({"type": "Follow"}, handler) good_message = {"type": "Follow"} router.dispatch(good_message, context={ "activity": a, "inbox_items": ii.__class__.objects.all() }) ii.refresh_from_db() group_send.assert_called_once_with( "user.{}.inbox".format(ii.actor.user.pk), { "type": "event.send", "text": "", "data": { "type": "inbox.item_added", "item": api_serializers.InboxItemSerializer(ii).data, }, }, )
def test_user_can_list_inbox_items(factories, logged_in_api_client): actor = logged_in_api_client.user.create_actor() ii = factories["federation.InboxItem"](activity__type="Follow", actor=actor, type="to") factories["federation.InboxItem"](activity__type="Follow", actor=actor, type="cc") factories["federation.InboxItem"](activity__type="Follow", type="to") url = reverse("api:v1:federation:inbox-list") response = logged_in_api_client.get(url) assert response.status_code == 200 assert response.data == { "count": 1, "results": [api_serializers.InboxItemSerializer(ii).data], "next": None, "previous": None, }