2019-09-27 19:12:12 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-01 21:08:45 -08:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-09-27 19:12:12 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|
|
|
use Pleroma.Web.ConnCase
|
|
|
|
|
|
|
|
alias Pleroma.Web.CommonAPI
|
|
|
|
|
2019-09-28 19:18:34 -07:00
|
|
|
describe "POST /api/v1/pleroma/scrobble" do
|
2019-12-19 06:23:27 -08:00
|
|
|
test "works correctly" do
|
|
|
|
%{conn: conn} = oauth_access(["write"])
|
2019-09-27 19:12:12 -07:00
|
|
|
|
|
|
|
conn =
|
2019-12-19 06:23:27 -08:00
|
|
|
post(conn, "/api/v1/pleroma/scrobble", %{
|
2019-09-27 19:12:12 -07:00
|
|
|
"title" => "lain radio episode 1",
|
|
|
|
"artist" => "lain",
|
|
|
|
"album" => "lain radio",
|
|
|
|
"length" => "180000"
|
|
|
|
})
|
|
|
|
|
|
|
|
assert %{"title" => "lain radio episode 1"} = json_response(conn, 200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-28 17:35:40 -07:00
|
|
|
describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
|
2019-12-19 06:23:27 -08:00
|
|
|
test "works correctly" do
|
|
|
|
%{user: user, conn: conn} = oauth_access(["read"])
|
2019-09-27 19:12:12 -07:00
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
|
|
|
"title" => "lain radio episode 1",
|
|
|
|
"artist" => "lain",
|
|
|
|
"album" => "lain radio"
|
|
|
|
})
|
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
|
|
|
"title" => "lain radio episode 2",
|
|
|
|
"artist" => "lain",
|
|
|
|
"album" => "lain radio"
|
|
|
|
})
|
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
|
|
|
"title" => "lain radio episode 3",
|
|
|
|
"artist" => "lain",
|
|
|
|
"album" => "lain radio"
|
|
|
|
})
|
|
|
|
|
2019-12-19 06:23:27 -08:00
|
|
|
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
|
2019-09-27 19:12:12 -07:00
|
|
|
|
|
|
|
result = json_response(conn, 200)
|
|
|
|
|
|
|
|
assert length(result) == 3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|