Merge branch 'openapi/pleroma-api/scrobble' into 'develop'
Add OpenAPI spec for PleromaAPI.ScrobbleController See merge request pleroma/pleroma!2559
This commit is contained in:
commit
5a149e5788
10 changed files with 206 additions and 78 deletions
|
|
@ -841,10 +841,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"album" => "lain radio",
|
||||
"artist" => "lain",
|
||||
"length" => 180_000
|
||||
title: "lain radio episode 1",
|
||||
album: "lain radio",
|
||||
artist: "lain",
|
||||
length: 180_000
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -859,11 +859,11 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"album" => "lain radio",
|
||||
"artist" => "lain",
|
||||
"length" => 180_000,
|
||||
"visibility" => "private"
|
||||
title: "lain radio episode 1",
|
||||
album: "lain radio",
|
||||
artist: "lain",
|
||||
length: 180_000,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
|
|||
|
|
@ -620,14 +620,4 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert status.visibility == "list"
|
||||
end
|
||||
|
||||
test "successfully renders a Listen activity (pleroma extension)" do
|
||||
listen_activity = insert(:listen)
|
||||
|
||||
status = StatusView.render("listen.json", activity: listen_activity)
|
||||
|
||||
assert status.length == listen_activity.data["object"]["length"]
|
||||
assert status.title == listen_activity.data["object"]["title"]
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
%{conn: conn} = oauth_access(["write"])
|
||||
|
||||
conn =
|
||||
post(conn, "/api/v1/pleroma/scrobble", %{
|
||||
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"
|
||||
})
|
||||
|
||||
assert %{"title" => "lain radio episode 1"} = json_response(conn, 200)
|
||||
assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -29,28 +31,28 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio"
|
||||
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"
|
||||
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"
|
||||
title: "lain radio episode 3",
|
||||
artist: "lain",
|
||||
album: "lain radio"
|
||||
})
|
||||
|
||||
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
|
||||
|
||||
result = json_response(conn, 200)
|
||||
result = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
assert length(result) == 3
|
||||
end
|
||||
|
|
|
|||
20
test/web/pleroma_api/views/scrobble_view_test.exs
Normal file
20
test/web/pleroma_api/views/scrobble_view_test.exs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.PleromaAPI.StatusViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.PleromaAPI.ScrobbleView
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "successfully renders a Listen activity (pleroma extension)" do
|
||||
listen_activity = insert(:listen)
|
||||
|
||||
status = ScrobbleView.render("show.json", activity: listen_activity)
|
||||
|
||||
assert status.length == listen_activity.data["object"]["length"]
|
||||
assert status.title == listen_activity.data["object"]["title"]
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue