X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Ftwitter_api%2Ftwitter_api_test.exs;h=fcb3fd8bd9ecc0a4cdf024e2f5f301d80277f42b;hb=9c1b36856b97a7f86e60ad23ef374449c1910c7a;hp=48ddbcf506ecd76ef79b1853df6ea95c08b784a8;hpb=c57f37bd36702fa8865366fbfaea9ac3f28dfad3;p=akkoma diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 48ddbcf50..fcb3fd8bd 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -4,10 +4,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do use Pleroma.DataCase - alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView} - alias Pleroma.{Activity, User, Object, Repo, UserInviteToken} + alias Pleroma.Activity + alias Pleroma.Object + alias Pleroma.Repo + alias Pleroma.User + alias Pleroma.UserInviteToken alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.TwitterAPI.ActivityView + alias Pleroma.Web.TwitterAPI.TwitterAPI + alias Pleroma.Web.TwitterAPI.UserView import Pleroma.Factory @@ -270,7 +275,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user} = TwitterAPI.register_user(data) - fetched_user = Repo.get_by(User, nickname: "lain") + fetched_user = User.get_by_nickname("lain") assert UserView.render("show.json", %{user: user}) == UserView.render("show.json", %{user: fetched_user}) @@ -288,7 +293,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user} = TwitterAPI.register_user(data) - fetched_user = Repo.get_by(User, nickname: "lain") + fetched_user = User.get_by_nickname("lain") assert UserView.render("show.json", %{user: user}) == UserView.render("show.json", %{user: fetched_user}) @@ -316,7 +321,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert user.info.confirmation_pending - Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user)) + Swoosh.TestAssertions.assert_email_sent( + Pleroma.Emails.UserEmail.account_confirmation_email(user) + ) end test "it registers a new user and parses mentions in the bio" do @@ -364,7 +371,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user} = TwitterAPI.register_user(data) - fetched_user = Repo.get_by(User, nickname: "vinny") + fetched_user = User.get_by_nickname("vinny") token = Repo.get_by(UserInviteToken, token: token.token) assert token.used == true @@ -388,7 +395,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:error, msg} = TwitterAPI.register_user(data) assert msg == "Invalid token" - refute Repo.get_by(User, nickname: "GrimReaper") + refute User.get_by_nickname("GrimReaper") end @moduletag skip: "needs 'registrations_open: false' in config" @@ -409,7 +416,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:error, msg} = TwitterAPI.register_user(data) assert msg == "Expired token" - refute Repo.get_by(User, nickname: "GrimReaper") + refute User.get_by_nickname("GrimReaper") end test "it returns the error on registration problems" do @@ -424,7 +431,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:error, error_object} = TwitterAPI.register_user(data) assert is_binary(error_object[:error]) - refute Repo.get_by(User, nickname: "lain") + refute User.get_by_nickname("lain") end test "it assigns an integer conversation_id" do @@ -440,22 +447,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" @@ -467,6 +458,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do # Also fetches the feed. # assert Activity.get_create_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status") + # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength end end end