Skip to content
Snippets Groups Projects
test_activity.py 1.27 KiB
Newer Older
  • Learn to ignore specific revisions
  • Eliot Berriot's avatar
    Eliot Berriot committed
    from funkwhale_api.federation import activity, serializers
    
    def test_deliver(factories, r_mock, mocker, settings):
        settings.CELERY_TASK_ALWAYS_EAGER = True
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        to = factories["federation.Actor"]()
        mocker.patch("funkwhale_api.federation.actors.get_actor", return_value=to)
        sender = factories["federation.Actor"]()
    
    Eliot Berriot's avatar
    Eliot Berriot committed
            "id": "http://test.federation/activity",
            "type": "Create",
            "actor": sender.url,
            "object": {
                "id": "http://test.federation/note",
                "type": "Note",
                "content": "Hello",
            },
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        activity.deliver(ac, to=[to.url], on_behalf_of=sender)
    
        request = r_mock.request_history[0]
    
        assert r_mock.called is True
        assert r_mock.call_count == 1
        assert request.url == to.inbox_url
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        assert request.headers["content-type"] == "application/activity+json"
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        deliver = mocker.patch("funkwhale_api.federation.activity.deliver")
        follow = factories["federation.Follow"](approved=None)
    
        expected_accept = serializers.AcceptFollowSerializer(follow).data
        activity.accept_follow(follow)
    
            expected_accept, to=[follow.actor.url], on_behalf_of=follow.target