Example #1
0
def test_inbox_delete_audio(factories):
    activity = factories["federation.Activity"]()

    upload = factories["music.Upload"]()
    library = upload.library
    payload = {
        "type": "Delete",
        "actor": library.actor.fid,
        "object": {
            "type": "Audio",
            "id": [upload.fid]
        },
    }

    routes.inbox_delete_audio(
        payload,
        context={
            "actor": library.actor,
            "raise_exception": True,
            "activity": activity
        },
    )

    with pytest.raises(upload.__class__.DoesNotExist):
        upload.refresh_from_db()
Example #2
0
def test_inbox_delete_audio_impostor(factories):
    activity = factories["federation.Activity"]()
    impostor = factories["federation.Actor"]()
    upload = factories["music.Upload"]()
    library = upload.library
    payload = {
        "type": "Delete",
        "actor": library.actor.fid,
        "object": {
            "type": "Audio",
            "id": [upload.fid]
        },
    }

    routes.inbox_delete_audio(
        payload,
        context={
            "actor": impostor,
            "raise_exception": True,
            "activity": activity
        },
    )

    # not deleted, should still be here
    upload.refresh_from_db()
Example #3
0
def test_inbox_delete_audio_channel(factories):
    activity = factories["federation.Activity"]()
    channel = factories["audio.Channel"]()
    upload = factories["music.Upload"](track__artist=channel.artist)
    payload = {
        "type": "Delete",
        "actor": channel.actor.fid,
        "object": {
            "type": "Audio",
            "id": [upload.fid]
        },
    }

    routes.inbox_delete_audio(
        payload,
        context={
            "actor": channel.actor,
            "raise_exception": True,
            "activity": activity
        },
    )

    with pytest.raises(upload.__class__.DoesNotExist):
        upload.refresh_from_db()