defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
use Pleroma.DataCase
alias Pleroma.Builders.{UserBuilder, ActivityBuilder}
- alias Pleroma.Web.TwitterAPI.{TwitterAPI,UserView,Utils}
+ alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView}
+ alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.{Activity, User, Object, Repo}
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
alias Pleroma.Web.ActivityPub.ActivityPub
assert msg == "Not subscribed!"
end
+ test "Block another user using user_id" do
+ user = insert(:user)
+ blocked = insert(:user)
+
+ {:ok, user, blocked} = TwitterAPI.block(user, %{"user_id" => blocked.id})
+ assert User.blocks?(user, blocked)
+ end
+
+ test "Block another user using screen_name" do
+ user = insert(:user)
+ blocked = insert(:user)
+
+ {:ok, user, blocked} = TwitterAPI.block(user, %{"screen_name" => blocked.nickname})
+ assert User.blocks?(user, blocked)
+ end
+
+ test "Unblock another user using user_id" do
+ unblocked = insert(:user)
+ user = insert(:user)
+ User.block(user, unblocked)
+
+ {:ok, user, unblocked} = TwitterAPI.unblock(user, %{"user_id" => unblocked.id})
+ assert user.info["blocks"] == []
+ end
+
+ test "Unblock another user using screen_name" do
+ unblocked = insert(:user)
+ user = insert(:user)
+ User.block(user, unblocked)
+
+ {:ok, user, unblocked} = TwitterAPI.unblock(user, %{"screen_name" => unblocked.nickname})
+ assert user.info["blocks"] == []
+ end
+
test "fetch statuses in a context using the conversation id" do
{:ok, user} = UserBuilder.insert()
{:ok, activity} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
{:ok, represented} = TwitterAPI.get_external_profile(user, id)
remote = User.get_by_ap_id(id)
- assert represented == UserView.render("show.json", %{user: remote, for: user})
+ assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]
# Also fetches the feed.
assert Activity.get_create_activity_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")