diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-04-15 13:54:46 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-04-15 13:54:46 +0200 |
commit | 60c60de330fe8fe03594da89831351099c8c9037 (patch) | |
tree | 8f5e0c83f8e0045eb73e2d991f5e1ae16d99dbd9 /test | |
parent | 21c397820f5feffc5d68ccfb578e2d6765052a3b (diff) | |
download | pleroma-60c60de330fe8fe03594da89831351099c8c9037.tar.gz |
Add announcements / retweets to TwAPI.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/twitter_api/representers/activity_representer_test.exs | 27 | ||||
-rw-r--r-- | test/web/twitter_api/twitter_api_test.exs | 11 |
2 files changed, 36 insertions, 2 deletions
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index d1f9e00c8..a9129bccc 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -6,6 +6,26 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do alias Pleroma.Builders.UserBuilder import Pleroma.Factory + test "an announce activity" do + user = insert(:user) + note_activity = insert(:note_activity) + activity_actor = Repo.get_by(User, ap_id: note_activity.data["actor"]) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + + {:ok, announce_activity, _object} = ActivityPub.announce(user, object) + note_activity = Activity.get_by_ap_id(note_activity.data["id"]) + + status = ActivityRepresenter.to_map(announce_activity, %{users: [user, activity_actor], announced_activity: note_activity, for: user}) + + assert status["id"] == announce_activity.id + assert status["user"] == UserRepresenter.to_map(user, %{for: user}) + + retweeted_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user}) + assert retweeted_status["repeated"] == true + + assert status["retweeted_status"] == retweeted_status + end + test "a like activity" do user = insert(:user) note_activity = insert(:note_activity) @@ -65,7 +85,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "attachment" => [ object ], - "like_count" => 5 + "like_count" => 5, + "announcement_count" => 3 }, "published" => date } @@ -90,7 +111,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do UserRepresenter.to_map(mentioned_user, %{for: follower}) ], "fave_num" => 5, - "favorited" => false + "repeat_num" => 3, + "favorited" => false, + "repeated" => false } assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index fd9908b9f..71b0d8b12 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -209,6 +209,17 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert status["fave_num"] == 0 end + test "it retweets a status and returns the retweet" do + user = insert(:user) + note_activity = insert(:note_activity) + activity_user = Repo.get_by!(User, ap_id: note_activity.data["actor"]) + + {:ok, status} = TwitterAPI.retweet(user, note_activity) + updated_activity = Activity.get_by_ap_id(note_activity.data["id"]) + + assert status == ActivityRepresenter.to_map(updated_activity, %{user: activity_user, for: user}) + end + setup do Supervisor.terminate_child(Pleroma.Supervisor, ConCache) Supervisor.restart_child(Pleroma.Supervisor, ConCache) |