diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2019-09-28 02:12:12 +0000 |
---|---|---|
committer | Ariadne Conill <ariadne@dereferenced.org> | 2019-09-30 10:39:17 +0000 |
commit | 7cad6ea67a47df2776a15dd69b9e408c517800e6 (patch) | |
tree | 1a2089a46688d5eaffa8e3618edf735ea390334f /test | |
parent | 2c82d8603bb4c3f7281023752dc78aa31a814ab6 (diff) | |
download | pleroma-7cad6ea67a47df2776a15dd69b9e408c517800e6.tar.gz |
pleroma api: hook up scrobbler controller
Diffstat (limited to 'test')
-rw-r--r-- | test/web/pleroma_api/controllers/scrobble_controller_test.exs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/web/pleroma_api/controllers/scrobble_controller_test.exs b/test/web/pleroma_api/controllers/scrobble_controller_test.exs new file mode 100644 index 000000000..8cbb5889e --- /dev/null +++ b/test/web/pleroma_api/controllers/scrobble_controller_test.exs @@ -0,0 +1,63 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do + use Pleroma.Web.ConnCase + + alias Pleroma.Web.CommonAPI + import Pleroma.Factory + + describe "POST /api/v1/pleroma/now-playing" do + test "works correctly", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> post("/api/v1/pleroma/now-playing", %{ + "title" => "lain radio episode 1", + "artist" => "lain", + "album" => "lain radio", + "length" => "180000" + }) + + assert %{"title" => "lain radio episode 1"} = json_response(conn, 200) + end + end + + describe "GET /api/v1/pleroma/accounts/:id/now-playing" do + test "works correctly", %{conn: conn} do + user = insert(:user) + + {: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" + }) + + conn = + conn + |> get("/api/v1/pleroma/accounts/#{user.id}/now-playing") + + result = json_response(conn, 200) + + assert length(result) == 3 + end + end +end |