Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F74273869
scrobble_controller_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
scrobble_controller_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.PleromaAPI.ScrobbleControllerTest
do
use
Pleroma.Web.ConnCase
,
async
:
true
alias
Pleroma.Web.CommonAPI
describe
"POST /api/v1/pleroma/scrobble"
do
test
"works correctly"
do
%{
conn
:
conn
}
=
oauth_access
([
"write"
])
conn
=
conn
|>
put_req_header
(
"content-type"
,
"application/json"
)
|>
post
(
"/api/v1/pleroma/scrobble"
,
%{
"title"
=>
"lain radio episode 1"
,
"artist"
=>
"lain"
,
"album"
=>
"lain radio"
,
"length"
=>
"180000"
,
"external_link"
=>
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
})
assert
%{
"title"
=>
"lain radio episode 1"
,
"external_link"
=>
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
}
=
json_response_and_validate_schema
(
conn
,
200
)
end
test
"external_link fallback"
do
%{
conn
:
conn
}
=
oauth_access
([
"write"
])
conn
=
conn
|>
put_req_header
(
"content-type"
,
"application/json"
)
|>
post
(
"/api/v1/pleroma/scrobble"
,
%{
"title"
=>
"lain radio episode 2"
,
"artist"
=>
"lain"
,
"album"
=>
"lain radio"
,
"length"
=>
"180000"
,
"externalLink"
=>
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
})
assert
%{
"title"
=>
"lain radio episode 2"
,
"external_link"
=>
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
}
=
json_response_and_validate_schema
(
conn
,
200
)
end
end
describe
"GET /api/v1/pleroma/accounts/:id/scrobbles"
do
test
"works correctly"
do
%{
user
:
user
,
conn
:
conn
}
=
oauth_access
([
"read"
])
{
:ok
,
_activity
}
=
CommonAPI
.
listen
(
user
,
%{
title
:
"lain radio episode 1"
,
artist
:
"lain"
,
album
:
"lain radio"
,
external_link
:
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+1"
})
{
:ok
,
_activity
}
=
CommonAPI
.
listen
(
user
,
%{
title
:
"lain radio episode 2"
,
artist
:
"lain"
,
album
:
"lain radio"
,
external_link
:
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+2"
})
{
:ok
,
_activity
}
=
CommonAPI
.
listen
(
user
,
%{
title
:
"lain radio episode 3"
,
artist
:
"lain"
,
album
:
"lain radio"
,
external_link
:
"https://www.last.fm/music/lain/lain+radio/lain+radio+episode+3"
})
conn
=
get
(
conn
,
"/api/v1/pleroma/accounts/
#{
user
.
id
}
/scrobbles"
)
result
=
json_response_and_validate_schema
(
conn
,
200
)
assert
length
(
result
)
==
3
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 25, 8:21 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1321620
Default Alt Text
scrobble_controller_test.exs (2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment