Add an ostatus representer for like activities.
[akkoma] / test / web / ostatus / ostatus_test.exs
index 3edd39911973feb5a6d310d6c8bfdad628c6fbbb..3951dbc9cd72328bc042145bf3dfe4c57267ab3a 100644 (file)
@@ -2,6 +2,12 @@ defmodule Pleroma.Web.OStatusTest do
   use Pleroma.DataCase
   alias Pleroma.Web.OStatus
 
+  test "don't insert create notes twice" do
+    incoming = File.read!("test/fixtures/incoming_note_activity.xml")
+    {:ok, [_activity]} = OStatus.handle_incoming(incoming)
+    assert {:ok, [{:error, "duplicate activity"}]} == OStatus.handle_incoming(incoming)
+  end
+
   test "handle incoming note - GS, Salmon" do
     incoming = File.read!("test/fixtures/incoming_note_activity.xml")
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
@@ -12,6 +18,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
     assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
     assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
+    assert activity.local == false
   end
 
   test "handle incoming notes - GS, subscription" do
@@ -58,6 +65,7 @@ defmodule Pleroma.Web.OStatusTest do
       assert user.local == false
       assert user.info["uri"] == uri
       assert user.ap_id == uri
+      assert user.avatar["type"] == "Image"
 
       {:ok, user_again} = OStatus.find_or_make_user(uri)
 
@@ -82,7 +90,8 @@ defmodule Pleroma.Web.OStatusTest do
         topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
         uri: "https://social.heldscal.la/user/29191",
         host: "social.heldscal.la",
-        fqn: user
+        fqn: user,
+        avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
       }
       assert data == expected
     end
@@ -103,7 +112,8 @@ defmodule Pleroma.Web.OStatusTest do
         topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
         uri: "https://social.heldscal.la/user/29191",
         host: "social.heldscal.la",
-        fqn: user
+        fqn: user,
+        avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
       }
       assert data == expected
     end