X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=test%2Fweb%2Ftwitter_api%2Ftwitter_api_test.exs;h=bf063a0dec5307d93a750c89427d4155a5b5661d;hb=7101ba1a21ded292ba057f9aadec1756914b45e0;hp=6b4cefacf8965124a4d6ac7f4c969e3e495aa2d9;hpb=aef3a3ca46afb98a93e1893162fb012ce433c368;p=akkoma
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index 6b4cefacf..bf063a0de 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
alias Pleroma.Activity
alias Pleroma.Object
alias Pleroma.Repo
+ alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -46,7 +47,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
- object = Object.normalize(activity.data["object"])
+ object = Object.normalize(activity)
expected_text =
"Hello again, @shp.<script></script>
This is on another :firefox: line. #2hu #epic #phantasmagoric
image.jpg"
@@ -78,7 +79,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert activity.data["object"] == object.data["id"]
- user = User.get_by_ap_id(user.ap_id)
+ user = User.get_cached_by_ap_id(user.ap_id)
assert user.info.note_count == 1
end
@@ -91,7 +92,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
- object = Object.normalize(activity.data["object"])
+ object = Object.normalize(activity)
input = %{
"status" => "Here's your (you).",
@@ -99,7 +100,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, reply = %Activity{}} = TwitterAPI.create_status(user, input)
- reply_object = Object.normalize(reply.data["object"])
+ reply_object = Object.normalize(reply)
assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
@@ -116,8 +117,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, user, followed, _activity} = TwitterAPI.follow(user, %{"user_id" => followed.id})
assert User.ap_followers(followed) in user.following
- {:error, msg} = TwitterAPI.follow(user, %{"user_id" => followed.id})
- assert msg == "Could not follow user: #{followed.nickname} is already on your list."
+ {:ok, _, _, _} = TwitterAPI.follow(user, %{"user_id" => followed.id})
end
test "Follow another user using screen_name" do
@@ -129,11 +129,10 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert User.ap_followers(followed) in user.following
- followed = User.get_by_ap_id(followed.ap_id)
+ followed = User.get_cached_by_ap_id(followed.ap_id)
assert followed.info.follower_count == 1
- {:error, msg} = TwitterAPI.follow(user, %{"screen_name" => followed.nickname})
- assert msg == "Could not follow user: #{followed.nickname} is already on your list."
+ {:ok, _, _, _} = TwitterAPI.follow(user, %{"screen_name" => followed.nickname})
end
test "Unfollow another user using user_id" do
@@ -218,7 +217,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
assert ActivityView.render("activity.json", %{activity: updated_activity})["fave_num"] == 1
- object = Object.normalize(note_activity.data["object"])
+ object = Object.normalize(note_activity)
assert object.data["like_count"] == 1
@@ -226,7 +225,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, _status} = TwitterAPI.fav(other_user, note_activity.id)
- object = Object.normalize(note_activity.data["object"])
+ object = Object.normalize(note_activity)
assert object.data["like_count"] == 2
@@ -237,7 +236,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
test "it unfavorites a status, returns the updated activity" do
user = insert(:user)
note_activity = insert(:note_activity)
- object = Object.get_by_ap_id(note_activity.data["object"]["id"])
+ object = Object.normalize(note_activity)
{:ok, _like_activity, _object} = ActivityPub.like(user, object)
updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
@@ -281,7 +280,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("lain")
+ fetched_user = User.get_cached_by_nickname("lain")
assert UserView.render("show.json", %{user: user}) ==
UserView.render("show.json", %{user: fetched_user})
@@ -299,7 +298,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("lain")
+ fetched_user = User.get_cached_by_nickname("lain")
assert UserView.render("show.json", %{user: user}) ==
UserView.render("show.json", %{user: fetched_user})
@@ -323,6 +322,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, user} = TwitterAPI.register_user(data)
+ ObanHelpers.perform_all()
assert user.info.confirmation_pending
@@ -394,7 +394,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("vinny")
+ fetched_user = User.get_cached_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token)
assert invite.used == true
@@ -417,7 +417,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Invalid token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
test "returns error on expired token" do
@@ -437,7 +437,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
end
@@ -462,7 +462,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
check_fn = fn invite ->
data = Map.put(data, "token", invite.token)
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("vinny")
+ fetched_user = User.get_cached_by_nickname("vinny")
assert UserView.render("show.json", %{user: user}) ==
UserView.render("show.json", %{user: fetched_user})
@@ -499,7 +499,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("vinny")
+ refute User.get_cached_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token)
refute invite.used
@@ -534,7 +534,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("vinny")
+ fetched_user = User.get_cached_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token)
assert invite.used == true
@@ -555,7 +555,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
end
@@ -585,7 +585,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("vinny")
+ fetched_user = User.get_cached_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token)
refute invite.used
@@ -610,7 +610,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
}
{:ok, user} = TwitterAPI.register_user(data)
- fetched_user = User.get_by_nickname("vinny")
+ fetched_user = User.get_cached_by_nickname("vinny")
invite = Repo.get_by(UserInviteToken, token: invite.token)
assert invite.used == true
@@ -630,7 +630,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
test "returns error on overdue date" do
@@ -650,7 +650,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
test "returns error on with overdue date and after max" do
@@ -672,7 +672,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, msg} = TwitterAPI.register_user(data)
assert msg == "Expired token"
- refute User.get_by_nickname("GrimReaper")
+ refute User.get_cached_by_nickname("GrimReaper")
end
end
@@ -688,7 +688,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:error, error_object} = TwitterAPI.register_user(data)
assert is_binary(error_object[:error])
- refute User.get_by_nickname("lain")
+ refute User.get_cached_by_nickname("lain")
end
test "it assigns an integer conversation_id" do
@@ -709,7 +709,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
id = "https://mastodon.social/users/lambadalambda"
user = insert(:user)
{:ok, represented} = TwitterAPI.get_external_profile(user, id)
- remote = User.get_by_ap_id(id)
+ remote = User.get_cached_by_ap_id(id)
assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]