aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-03-30 17:07:03 +0200
committerRoger Braun <roger@rogerbraun.net>2017-03-30 17:07:22 +0200
commit73df2f8e5e2d0e2b125df8848c2dd7f2a73f1c03 (patch)
treec65c5d46dc71839a6d94e79e8ada42c4dda68165 /test
parent42c90855ba826a93cada909f105307c95dc0e130 (diff)
downloadpleroma-73df2f8e5e2d0e2b125df8848c2dd7f2a73f1c03.tar.gz
Add attachments to the TwAPI.
Diffstat (limited to 'test')
-rw-r--r--test/web/twitter_api/representers/activity_representer_test.exs26
-rw-r--r--test/web/twitter_api/representers/object_representer_test.exs5
-rw-r--r--test/web/twitter_api/twitter_api_test.exs21
3 files changed, 45 insertions, 7 deletions
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs
index 376d31575..96e6dc98e 100644
--- a/test/web/twitter_api/representers/activity_representer_test.exs
+++ b/test/web/twitter_api/representers/activity_representer_test.exs
@@ -1,13 +1,27 @@
defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
use Pleroma.DataCase
- alias Pleroma.{User, Activity}
- alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter}
+ alias Pleroma.{User, Activity, Object}
+ alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter, ObjectRepresenter}
alias Pleroma.Builders.UserBuilder
test "an activity" do
{:ok, user} = UserBuilder.insert
{:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
+ object = %Object{
+ data: %{
+ "type" => "Image",
+ "url" => [
+ %{
+ "type" => "Link",
+ "mediaType" => "image/jpg",
+ "href" => "http://example.org/image.jpg"
+ }
+ ],
+ "uuid" => 1
+ }
+ }
+
content = "Some content"
date = DateTime.utc_now() |> DateTime.to_iso8601
@@ -19,6 +33,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
User.ap_followers(user),
"https://www.w3.org/ns/activitystreams#Public"
],
+ "attachment" => [
+ object
+ ],
"actor" => User.ap_id(user),
"object" => %{
"published" => date,
@@ -42,7 +59,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"is_post_verb" => true,
"created_at" => date,
"in_reply_to_status_id" => 213123,
- "statusnet_conversation_id" => 4711
+ "statusnet_conversation_id" => 4711,
+ "attachments" => [
+ ObjectRepresenter.to_map(object)
+ ]
}
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
diff --git a/test/web/twitter_api/representers/object_representer_test.exs b/test/web/twitter_api/representers/object_representer_test.exs
index fc6e0aff9..791b30237 100644
--- a/test/web/twitter_api/representers/object_representer_test.exs
+++ b/test/web/twitter_api/representers/object_representer_test.exs
@@ -14,12 +14,13 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do
"mediaType" => "sometype",
"href" => "someurl"
}
- ]
+ ],
+ "uuid" => 6
}
}
expected_object = %{
- id: 5,
+ id: 6,
url: "someurl",
mimetype: "sometype",
oembed: false
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index dcffab2b8..97657eae0 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -2,13 +2,28 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
use Pleroma.DataCase
alias Pleroma.Builders.{UserBuilder, ActivityBuilder}
alias Pleroma.Web.TwitterAPI.TwitterAPI
- alias Pleroma.{Activity, User}
+ alias Pleroma.{Activity, User, Object, Repo}
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
test "create a status" do
user = UserBuilder.build
+ object_data = %{
+ "type" => "Image",
+ "url" => [
+ %{
+ "type" => "Link",
+ "mediaType" => "image/jpg",
+ "href" => "http://example.org/image.jpg"
+ }
+ ],
+ "uuid" => 1
+ }
+
+ object = Repo.insert!(%Object{data: object_data})
+
input = %{
- "status" => "Hello again."
+ "status" => "Hello again.",
+ "media_ids" => [object.id]
}
{ :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
@@ -24,6 +39,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert is_binary(get_in(activity.data, ["object", "context"]))
assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id
assert get_in(activity.data, ["statusnetConversationId"]) == activity.id
+
+ assert is_list(activity.data["attachment"])
end
test "create a status that is a reply" do