summaryrefslogtreecommitdiff
path: root/test/web/mastodon_api/mastodon_api_controller_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-12 10:13:54 +0100
committerlain <lain@soykaf.club>2018-02-12 10:14:11 +0100
commit26ccb768d39515faa3b1db7f1371ecf2517eb6bf (patch)
treecad8d083afe1b126f6907cc6f9d1478c3e469656 /test/web/mastodon_api/mastodon_api_controller_test.exs
parent33a5d0a2385984168f7de063093c6a71c8b07b73 (diff)
downloadpleroma-26ccb768d39515faa3b1db7f1371ecf2517eb6bf.tar.gz
pleroma-26ccb768d39515faa3b1db7f1371ecf2517eb6bf.zip
Make test output easier to read.
Diffstat (limited to 'test/web/mastodon_api/mastodon_api_controller_test.exs')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs66
1 files changed, 36 insertions, 30 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index e4c59d9ff..a655fa74b 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -6,6 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
alias Pleroma.Web.{OStatus, CommonAPI}
import Pleroma.Factory
+ import ExUnit.CaptureLog
test "the home timeline", %{conn: conn} do
user = insert(:user)
@@ -31,23 +32,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
test "the public timeline", %{conn: conn} do
following = insert(:user)
- {:ok, _activity} = TwitterAPI.create_status(following, %{"status" => "test"})
- {:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
+ capture_log fn ->
+ {:ok, _activity} = TwitterAPI.create_status(following, %{"status" => "test"})
+ {:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
- conn = conn
- |> get("/api/v1/timelines/public", %{"local" => "False"})
+ conn = conn
+ |> get("/api/v1/timelines/public", %{"local" => "False"})
- assert length(json_response(conn, 200)) == 2
+ assert length(json_response(conn, 200)) == 2
- conn = build_conn()
- |> get("/api/v1/timelines/public", %{"local" => "True"})
+ conn = build_conn()
+ |> get("/api/v1/timelines/public", %{"local" => "True"})
- assert [%{"content" => "test"}] = json_response(conn, 200)
+ assert [%{"content" => "test"}] = json_response(conn, 200)
- conn = build_conn()
- |> get("/api/v1/timelines/public", %{"local" => "1"})
+ conn = build_conn()
+ |> get("/api/v1/timelines/public", %{"local" => "1"})
- assert [%{"content" => "test"}] = json_response(conn, 200)
+ assert [%{"content" => "test"}] = json_response(conn, 200)
+ end
end
test "posting a status", %{conn: conn} do
@@ -144,7 +147,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
other_user = insert(:user)
{:ok, activity} = TwitterAPI.create_status(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, [notification]} = Notification.create_notifications(activity)
+ {:ok, [_notification]} = Notification.create_notifications(activity)
conn = conn
|> assign(:user, user)
@@ -190,7 +193,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
other_user = insert(:user)
{:ok, activity} = TwitterAPI.create_status(other_user, %{"status" => "hi @#{user.nickname}"})
- {:ok, [notification]} = Notification.create_notifications(activity)
+ {:ok, [_notification]} = Notification.create_notifications(activity)
conn = conn
|> assign(:user, user)
@@ -338,15 +341,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
test "hashtag timeline", %{conn: conn} do
following = insert(:user)
- {:ok, activity} = TwitterAPI.create_status(following, %{"status" => "test #2hu"})
- {:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
-
- conn = conn
- |> get("/api/v1/timelines/tag/2hu")
+ capture_log fn ->
+ {:ok, activity} = TwitterAPI.create_status(following, %{"status" => "test #2hu"})
+ {:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
+ conn = conn
+ |> get("/api/v1/timelines/tag/2hu")
- assert [%{"id" => id}] = json_response(conn, 200)
+ assert [%{"id" => id}] = json_response(conn, 200)
- assert id == to_string(activity.id)
+ assert id == to_string(activity.id)
+ end
end
test "getting followers", %{conn: conn} do
@@ -381,14 +385,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> assign(:user, user)
|> post("/api/v1/accounts/#{other_user.id}/follow")
- assert %{"id" => id, "following" => true} = json_response(conn, 200)
+ assert %{"id" => _id, "following" => true} = json_response(conn, 200)
user = Repo.get(User, user.id)
conn = build_conn()
|> assign(:user, user)
|> post("/api/v1/accounts/#{other_user.id}/unfollow")
- assert %{"id" => id, "following" => false} = json_response(conn, 200)
+ assert %{"id" => _id, "following" => false} = json_response(conn, 200)
user = Repo.get(User, user.id)
conn = build_conn()
@@ -407,14 +411,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> assign(:user, user)
|> post("/api/v1/accounts/#{other_user.id}/block")
- assert %{"id" => id, "blocking" => true} = json_response(conn, 200)
+ assert %{"id" => _id, "blocking" => true} = json_response(conn, 200)
user = Repo.get(User, user.id)
conn = build_conn()
|> assign(:user, user)
|> post("/api/v1/accounts/#{other_user.id}/unblock")
- assert %{"id" => id, "blocking" => false} = json_response(conn, 200)
+ assert %{"id" => _id, "blocking" => false} = json_response(conn, 200)
end
test "getting a list of blocks", %{conn: conn} do
@@ -461,7 +465,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
test "account search", %{conn: conn} do
user = insert(:user)
- user_two = insert(:user, %{nickname: "shp@shitposter.club"})
+ _user_two = insert(:user, %{nickname: "shp@shitposter.club"})
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
conn = conn
@@ -495,12 +499,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
end
test "search fetches remote statuses", %{conn: conn} do
- conn = conn
- |> get("/api/v1/search", %{"q" => "https://shitposter.club/notice/2827873"})
- assert results = json_response(conn, 200)
+ capture_log fn ->
+ conn = conn
+ |> get("/api/v1/search", %{"q" => "https://shitposter.club/notice/2827873"})
+ assert results = json_response(conn, 200)
- [status] = results["statuses"]
- assert status["uri"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
+ [status] = results["statuses"]
+ assert status["uri"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
+ end
end
test "search fetches remote accounts", %{conn: conn} do