Example #1
0
def test_manage_upload_serializer(factories, now, to_api_date):
    upload = factories["music.Upload"]()

    expected = {
        "id": upload.id,
        "fid": upload.fid,
        "audio_file": upload.audio_file.url,
        "listen_url": upload.listen_url,
        "uuid": str(upload.uuid),
        "domain": upload.domain_name,
        "is_local": upload.is_local,
        "duration": upload.duration,
        "size": upload.size,
        "bitrate": upload.bitrate,
        "mimetype": upload.mimetype,
        "source": upload.source,
        "filename": upload.filename,
        "metadata": upload.metadata,
        "creation_date": to_api_date(upload.creation_date),
        "modification_date": to_api_date(upload.modification_date),
        "accessed_date": None,
        "import_date": None,
        "import_metadata": upload.import_metadata,
        "import_status": upload.import_status,
        "import_reference": upload.import_reference,
        "import_details": upload.import_details,
        "library":
        serializers.ManageNestedLibrarySerializer(upload.library).data,
        "track": serializers.ManageNestedTrackSerializer(upload.track).data,
    }
    s = serializers.ManageUploadSerializer(upload)

    assert s.data == expected
Example #2
0
def test_manage_album_serializer(factories, now, to_api_date):
    album = factories["music.Album"](attributed=True, with_cover=True)
    track = factories["music.Track"](album=album)
    expected = {
        "id":
        album.id,
        "domain":
        album.domain_name,
        "is_local":
        album.is_local,
        "fid":
        album.fid,
        "title":
        album.title,
        "mbid":
        album.mbid,
        "creation_date":
        to_api_date(album.creation_date),
        "release_date":
        album.release_date.isoformat(),
        "cover":
        common_serializers.AttachmentSerializer(album.attachment_cover).data,
        "artist":
        serializers.ManageNestedArtistSerializer(album.artist).data,
        "tracks": [serializers.ManageNestedTrackSerializer(track).data],
        "attributed_to":
        serializers.ManageBaseActorSerializer(album.attributed_to).data,
        "tags": [],
    }
    s = serializers.ManageAlbumSerializer(album)

    assert s.data == expected
Example #3
0
def test_manage_nested_track_serializer(factories, now, to_api_date):
    track = factories["music.Track"]()
    expected = {
        "id": track.id,
        "domain": track.domain_name,
        "is_local": track.is_local,
        "fid": track.fid,
        "title": track.title,
        "mbid": track.mbid,
        "creation_date": to_api_date(track.creation_date),
        "position": track.position,
        "disc_number": track.disc_number,
        "copyright": track.copyright,
        "license": track.license,
    }
    s = serializers.ManageNestedTrackSerializer(track)

    assert s.data == expected