Esempio n. 1
0
def test_get_podcasts(logged_in_api_client, factories, mocker):
    actor = logged_in_api_client.user.create_actor()
    channel = factories["audio.Channel"](external=True,
                                         library__privacy_level="everyone")
    upload1 = factories["music.Upload"](
        playable=True,
        track__artist=channel.artist,
        library=channel.library,
        bitrate=128000,
        duration=42,
    )
    upload2 = factories["music.Upload"](
        playable=True,
        track__artist=channel.artist,
        library=channel.library,
        bitrate=256000,
        duration=43,
    )
    factories["federation.Follow"](actor=actor,
                                   target=channel.actor,
                                   approved=True)
    factories["music.Upload"](import_status="pending",
                              track__artist=channel.artist)
    factories["audio.Channel"](external=True)
    factories["federation.Follow"]()
    url = reverse("api:subsonic-get_podcasts")
    assert url.endswith("getPodcasts") is True
    response = logged_in_api_client.get(url, {"f": "json"})
    assert response.status_code == 200
    assert response.data == {
        "podcasts": {
            "channel":
            [serializers.get_channel_data(channel, [upload2, upload1])],
        }
    }
Esempio n. 2
0
def test_channel_serializer(factories):
    description = factories["common.Content"]()
    channel = factories["audio.Channel"](
        external=True, artist__description=description, artist__with_cover=True
    )
    upload = factories["music.Upload"](
        playable=True, library=channel.library, duration=42
    )

    expected = {
        "id": str(channel.uuid),
        "url": channel.rss_url,
        "title": channel.artist.name,
        "description": description.as_plain_text,
        "coverArt": "at-{}".format(channel.artist.attachment_cover.uuid),
        "originalImageUrl": channel.artist.attachment_cover.url,
        "status": "completed",
        "episode": [serializers.get_channel_episode_data(upload, channel.uuid)],
    }
    data = serializers.get_channel_data(channel, [upload])
    assert data == expected