X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fweb%2Ftwitter_api%2Ftwitter_api_test.exs;h=405aa1221a1dfac9cb27259fb829d520f379c536;hb=a8e50d602ba25b2062e0e676e1dd115da64c2565;hp=ad932131ac2522ccf153d158368f0562ba7b4aaa;hpb=8075badafe60d396c236d8d6d911cbb60ae9c5b6;p=akkoma diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ad932131a..405aa1221 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -82,15 +82,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do test "fetch friends' statuses" do ActivityBuilder.public_and_non_public + {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]}) + {:ok, direct_activity} = ActivityBuilder.insert(%{"to" => ["some other id"]}) {:ok, user} = UserBuilder.insert(%{ap_id: "some other id", following: ["someguy/followers"]}) statuses = TwitterAPI.fetch_friend_statuses(user) activity_user = Repo.get_by(User, ap_id: activity.data["actor"]) - assert length(statuses) == 1 + assert length(statuses) == 2 assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: activity_user}) + assert Enum.at(statuses, 1) == ActivityRepresenter.to_map(direct_activity, %{user: activity_user, mentioned: [user]}) end test "fetch a single status" do @@ -105,26 +108,31 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do test "Follow another user" do { :ok, user } = UserBuilder.insert - { :ok, following } = UserBuilder.insert(%{nickname: "guy"}) + { :ok, followed } = UserBuilder.insert(%{nickname: "guy"}) - {:ok, user, following, activity } = TwitterAPI.follow(user, following.id) + { :ok, user, followed, activity } = TwitterAPI.follow(user, followed.id) user = Repo.get(User, user.id) follow = Repo.get(Activity, activity.id) - assert user.following == [User.ap_followers(following)] + assert user.following == [User.ap_followers(followed)] assert follow == activity + + { :error, msg } = TwitterAPI.follow(user, followed.id) + assert msg == "Could not follow user: #{followed.nickname} is already on your list." end test "Unfollow another user" do - { :ok, following } = UserBuilder.insert(%{nickname: "guy"}) - { :ok, user } = UserBuilder.insert(%{following: [User.ap_followers(following)]}) + { :ok, followed } = UserBuilder.insert(%{nickname: "guy"}) + { :ok, user } = UserBuilder.insert(%{following: [User.ap_followers(followed)]}) - {:ok, user, _following } = TwitterAPI.unfollow(user, following.id) + { :ok, user, _followed } = TwitterAPI.unfollow(user, followed.id) user = Repo.get(User, user.id) assert user.following == [] + { :error, msg } = TwitterAPI.unfollow(user, followed.id) + assert msg == "Not subscribed!" end test "fetch statuses in a context using the conversation id" do