- assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
- assert get_in(reply.data, ["statusnetConversationId"]) == get_in(activity.data, ["statusnetConversationId"])
- assert get_in(reply.data, ["object", "statusnetConversationId"]) == get_in(activity.data, ["object", "statusnetConversationId"])
- assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
- assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
- assert Enum.member?(get_in(reply.data, ["to"]), "some_cool_id")
- end
-
- test "fetch public statuses" do
- %{ public: activity, user: user } = ActivityBuilder.public_and_non_public
-
- follower = insert(:user, following: [User.ap_followers(user)])
-
- statuses = TwitterAPI.fetch_public_statuses(follower)
-
- assert length(statuses) == 1
- assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: user, for: follower})
- end
-
- test "fetch friends' statuses" do
- user = insert(:user, %{following: ["someguy/followers"]})
- {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]})
- {:ok, direct_activity} = ActivityBuilder.insert(%{"to" => [user.ap_id]})
-
- statuses = TwitterAPI.fetch_friend_statuses(user)
-
- activity_user = Repo.get_by(User, ap_id: activity.data["actor"])
- direct_activity_user = Repo.get_by(User, ap_id: direct_activity.data["actor"])
-
- 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: direct_activity_user, mentioned: [user]})
- end
-
- test "get a user by params" do
- user1_result = {:ok, user1} = UserBuilder.insert(%{ap_id: "some id", email: "test@pleroma"})
- {:ok, user2} = UserBuilder.insert(%{ap_id: "some other id", nickname: "testname2", email: "test2@pleroma"})
-
- assert {:error, "You need to specify screen_name or user_id"} == TwitterAPI.get_user(nil, nil)
- assert user1_result == TwitterAPI.get_user(nil, %{"user_id" => user1.id})
- assert user1_result == TwitterAPI.get_user(nil, %{"screen_name" => user1.nickname})
- assert user1_result == TwitterAPI.get_user(user1, nil)
- assert user1_result == TwitterAPI.get_user(user2, %{"user_id" => user1.id})
- assert user1_result == TwitterAPI.get_user(user2, %{"screen_name" => user1.nickname})
- assert {:error, "No user with such screen_name"} == TwitterAPI.get_user(nil, %{"screen_name" => "Satan"})
- assert {:error, "No user with such user_id"} == TwitterAPI.get_user(nil, %{"user_id" => 666})
- end
-
- test "fetch user's statuses" do
- {:ok, user1} = UserBuilder.insert(%{ap_id: "some id", email: "test@pleroma"})
- {:ok, user2} = UserBuilder.insert(%{ap_id: "some other id", nickname: "testname2", email: "test2@pleroma"})