diff options
| author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-05-20 04:00:46 +0000 | 
|---|---|---|
| committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-05-20 04:00:46 +0000 | 
| commit | 5a149e5788978d919020b81f6d454f1ece9b8983 (patch) | |
| tree | 71a245852bfc710d3fe986b30e3a2473db436f31 /test/web | |
| parent | 48bcb22146ba84c174521147e004fd26c666ca84 (diff) | |
| parent | 47ed9ee4411613cac81235f9751a8ccd0974e927 (diff) | |
| download | pleroma-5a149e5788978d919020b81f6d454f1ece9b8983.tar.gz pleroma-5a149e5788978d919020b81f6d454f1ece9b8983.zip  | |
Merge branch 'openapi/pleroma-api/scrobble' into 'develop'
Add OpenAPI spec for PleromaAPI.ScrobbleController
See merge request pleroma/pleroma!2559
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/common_api/common_api_test.exs | 18 | ||||
| -rw-r--r-- | test/web/mastodon_api/views/status_view_test.exs | 10 | ||||
| -rw-r--r-- | test/web/pleroma_api/controllers/scrobble_controller_test.exs | 26 | ||||
| -rw-r--r-- | test/web/pleroma_api/views/scrobble_view_test.exs | 20 | 
4 files changed, 43 insertions, 31 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index fd8299013..52e95397c 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -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) diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs index 5d7adbe29..43e3bdca1 100644 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@ -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 diff --git a/test/web/pleroma_api/controllers/scrobble_controller_test.exs b/test/web/pleroma_api/controllers/scrobble_controller_test.exs index 1b945040c..f39c07ac6 100644 --- a/test/web/pleroma_api/controllers/scrobble_controller_test.exs +++ b/test/web/pleroma_api/controllers/scrobble_controller_test.exs @@ -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 diff --git a/test/web/pleroma_api/views/scrobble_view_test.exs b/test/web/pleroma_api/views/scrobble_view_test.exs new file mode 100644 index 000000000..6bdb56509 --- /dev/null +++ b/test/web/pleroma_api/views/scrobble_view_test.exs @@ -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  | 
