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