mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 21:57:06 +02:00
Funkwhale: Implemented LovesExport
This commit is contained in:
parent
48c8843f91
commit
9316838d59
6 changed files with 446 additions and 13 deletions
|
@ -30,7 +30,7 @@ import (
|
|||
"go.uploadedlobster.com/scotty/models"
|
||||
)
|
||||
|
||||
func TestListenFromFunkwhale(t *testing.T) {
|
||||
func TestFunkwhaleListeningToListen(t *testing.T) {
|
||||
fwListen := funkwhale.Listening{
|
||||
CreationDate: "2023-11-09T23:59:29.022005Z",
|
||||
User: funkwhale.User{
|
||||
|
@ -57,7 +57,7 @@ func TestListenFromFunkwhale(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
listen := funkwhale.ListenFromFunkwhale(fwListen)
|
||||
listen := fwListen.ToListen()
|
||||
assert.Equal(t, time.Unix(1699574369, 0).Unix(), listen.ListenedAt.Unix())
|
||||
assert.Equal(t, fwListen.User.UserName, listen.UserName)
|
||||
assert.Equal(t, time.Duration(414*time.Second), listen.Duration)
|
||||
|
@ -72,3 +72,45 @@ func TestListenFromFunkwhale(t *testing.T) {
|
|||
assert.Equal(t, models.MBID(fwListen.Track.Artist.ArtistMbid), listen.ArtistMbids[0])
|
||||
assert.Equal(t, funkwhale.FunkwhaleClientName, listen.AdditionalInfo["media_player"])
|
||||
}
|
||||
|
||||
func TestFunkwhaleFavoriteTrackToLove(t *testing.T) {
|
||||
favorite := funkwhale.FavoriteTrack{
|
||||
CreationDate: "2023-11-09T23:59:29.022005Z",
|
||||
User: funkwhale.User{
|
||||
UserName: "outsidecontext",
|
||||
},
|
||||
Track: funkwhale.Track{
|
||||
Title: "Oweynagat",
|
||||
RecordingMbid: "c0a1fc94-5f04-4a5f-bc09-e5de0c49cd12",
|
||||
Position: 5,
|
||||
DiscNumber: 1,
|
||||
Tags: []string{"foo", "bar"},
|
||||
Artist: funkwhale.Artist{
|
||||
Name: "Dool",
|
||||
ArtistMbid: "24412926-c7bd-48e8-afad-8a285b42e131",
|
||||
},
|
||||
Album: funkwhale.Album{
|
||||
Title: "Here Now, There Then",
|
||||
ReleaseMbid: "d7f22677-9803-4d21-ba42-081b633a6f68",
|
||||
},
|
||||
Uploads: []funkwhale.Upload{
|
||||
{
|
||||
Duration: 414,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
love := favorite.ToLove()
|
||||
assert.Equal(t, time.Unix(1699574369, 0).Unix(), love.Created.Unix())
|
||||
assert.Equal(t, favorite.User.UserName, love.UserName)
|
||||
assert.Equal(t, time.Duration(414*time.Second), love.Duration)
|
||||
assert.Equal(t, favorite.Track.Title, love.TrackName)
|
||||
assert.Equal(t, favorite.Track.Album.Title, love.ReleaseName)
|
||||
assert.Equal(t, []string{favorite.Track.Artist.Name}, love.ArtistNames)
|
||||
assert.Equal(t, favorite.Track.Position, love.Track.TrackNumber)
|
||||
assert.Equal(t, favorite.Track.Tags, love.Track.Tags)
|
||||
assert.Equal(t, models.MBID(favorite.Track.RecordingMbid), love.RecordingMbid)
|
||||
assert.Equal(t, models.MBID(favorite.Track.Album.ReleaseMbid), love.ReleaseMbid)
|
||||
assert.Equal(t, models.MBID(favorite.Track.Artist.ArtistMbid), love.ArtistMbids[0])
|
||||
assert.Equal(t, funkwhale.FunkwhaleClientName, love.AdditionalInfo["media_player"])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue