common api: move context functions from twitterapi
This commit is contained in:
parent
bf8b29e080
commit
fea3696799
7 changed files with 52 additions and 54 deletions
|
|
@ -136,4 +136,20 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
assert output == expected
|
||||
end
|
||||
end
|
||||
|
||||
describe "context_to_conversation_id" do
|
||||
test "creates a mapping object" do
|
||||
conversation_id = Utils.context_to_conversation_id("random context")
|
||||
object = Object.get_by_ap_id("random context")
|
||||
|
||||
assert conversation_id == object.id
|
||||
end
|
||||
|
||||
test "returns an existing mapping for an existing object" do
|
||||
{:ok, object} = Object.context_mapping("random context") |> Repo.insert()
|
||||
conversation_id = Utils.context_to_conversation_id("random context")
|
||||
|
||||
assert conversation_id == object.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -445,22 +445,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
:ok
|
||||
end
|
||||
|
||||
describe "context_to_conversation_id" do
|
||||
test "creates a mapping object" do
|
||||
conversation_id = TwitterAPI.context_to_conversation_id("random context")
|
||||
object = Object.get_by_ap_id("random context")
|
||||
|
||||
assert conversation_id == object.id
|
||||
end
|
||||
|
||||
test "returns an existing mapping for an existing object" do
|
||||
{:ok, object} = Object.context_mapping("random context") |> Repo.insert()
|
||||
conversation_id = TwitterAPI.context_to_conversation_id("random context")
|
||||
|
||||
assert conversation_id == object.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "fetching a user by uri" do
|
||||
test "fetches a user by uri" do
|
||||
id = "https://mastodon.social/users/lambadalambda"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.TwitterAPI.ActivityView
|
||||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.Web.TwitterAPI.UserView
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
@ -129,7 +128,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
|
||||
result = ActivityView.render("activity.json", activity: activity)
|
||||
|
||||
convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
|
||||
expected = %{
|
||||
"activity_type" => "post",
|
||||
|
|
@ -177,7 +176,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
other_user = insert(:user, %{nickname: "shp"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
|
||||
|
||||
convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
|
||||
mocks = [
|
||||
{
|
||||
|
|
@ -197,7 +196,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
|
||||
assert result["statusnet_conversation_id"] == convo_id
|
||||
assert result["user"]
|
||||
refute called(TwitterAPI.context_to_conversation_id(:_))
|
||||
refute called(Utils.context_to_conversation_id(:_))
|
||||
refute called(User.get_cached_by_ap_id(user.ap_id))
|
||||
refute called(User.get_cached_by_ap_id(other_user.ap_id))
|
||||
end
|
||||
|
|
@ -280,7 +279,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
|
||||
{:ok, announce, _object} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"])
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue