2019-09-27 20:12:12 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-01 22:08:45 -07:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-09-27 20:12:12 -06: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 20:18:34 -06:00
|
|
|
describe "POST /api/v1/pleroma/scrobble" do
|
2019-12-19 07:23:27 -07:00
|
|
|
test "works correctly" do
|
|
|
|
%{conn: conn} = oauth_access(["write"])
|
2019-09-27 20:12:12 -06:00
|
|
|
|
|
|
|
conn =
|
2020-05-19 05:53:18 -06:00
|
|
|
conn
|
|
|
|
|> put_req_header("content-type", "application/json")
|
|
|
|
|> post("/api/v1/pleroma/scrobble", %{
|
2019-09-27 20:12:12 -06:00
|
|
|
"title" => "lain radio episode 1",
|
|
|
|
"artist" => "lain",
|
|
|
|
"album" => "lain radio",
|
|
|
|
"length" => "180000"
|
|
|
|
})
|
|
|
|
|
2020-05-19 05:53:18 -06:00
|
|
|
assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
|
2019-09-27 20:12:12 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-28 18:35:40 -06:00
|
|
|
describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
|
2019-12-19 07:23:27 -07:00
|
|
|
test "works correctly" do
|
|
|
|
%{user: user, conn: conn} = oauth_access(["read"])
|
2019-09-27 20:12:12 -06:00
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
2020-05-19 05:53:18 -06:00
|
|
|
title: "lain radio episode 1",
|
|
|
|
artist: "lain",
|
|
|
|
album: "lain radio"
|
2019-09-27 20:12:12 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
2020-05-19 05:53:18 -06:00
|
|
|
title: "lain radio episode 2",
|
|
|
|
artist: "lain",
|
|
|
|
album: "lain radio"
|
2019-09-27 20:12:12 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
{:ok, _activity} =
|
|
|
|
CommonAPI.listen(user, %{
|
2020-05-19 05:53:18 -06:00
|
|
|
title: "lain radio episode 3",
|
|
|
|
artist: "lain",
|
|
|
|
album: "lain radio"
|
2019-09-27 20:12:12 -06:00
|
|
|
})
|
|
|
|
|
2019-12-19 07:23:27 -07:00
|
|
|
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
|
2019-09-27 20:12:12 -06:00
|
|
|
|
2020-05-19 05:53:18 -06:00
|
|
|
result = json_response_and_validate_schema(conn, 200)
|
2019-09-27 20:12:12 -06:00
|
|
|
|
|
|
|
assert length(result) == 3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|