From 91065e1968e97d299aa708b938cbef18c2cd1271 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 2 Dec 2018 11:20:38 +0100 Subject: Fix background updating / handling. --- test/web/ostatus/ostatus_test.exs | 2 +- test/web/twitter_api/twitter_api_controller_test.exs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index baa8cac72..32bf6691b 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -337,7 +337,7 @@ defmodule Pleroma.Web.OStatusTest do %Pleroma.User.Info{ id: user.info.id, ap_enabled: false, - background: nil, + background: %{}, banner: %{}, blocks: [], deactivated: false, diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 89c176da7..539876323 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -24,6 +24,9 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> assign(:user, user) |> post(authenticated_twitter_api__path(conn, :update_banner), %{"banner" => new_banner}) |> json_response(200) + + user = Repo.get(User, user.id) + assert user.info.banner["type"] == "Image" end end @@ -39,6 +42,9 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> assign(:user, user) |> post(authenticated_twitter_api__path(conn, :update_background), %{"img" => new_bg}) |> json_response(200) + + user = Repo.get(User, user.id) + assert user.info.background["type"] == "Image" end end -- cgit v1.2.3 From ce98d5eb9b4d9c5a09b91a9d4d13bb48ba2b8453 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sun, 2 Dec 2018 22:03:53 +0300 Subject: Parse user's bio on register --- .../twitter_api/twitter_api_controller_test.exs | 5 ++-- test/web/twitter_api/twitter_api_test.exs | 28 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 89c176da7..a1eb09a05 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -949,18 +949,19 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do describe "POST /api/account/update_profile.json" do test "it updates a user's profile", %{conn: conn} do user = insert(:user) + user2 = insert(:user) conn = conn |> assign(:user, user) |> post("/api/account/update_profile.json", %{ "name" => "new name", - "description" => "new description" + "description" => "hi @#{user2.nickname}" }) user = Repo.get!(User, user.id) assert user.name == "new name" - assert user.bio == "new description" + assert user.bio == "hi @#{user2.nickname}" assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ec13b89d4..baeea5a9e 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -257,6 +257,34 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do UserView.render("show.json", %{user: fetched_user}) end + test "it registers a new user and parses mentions in the bio" do + data1 = %{ + "nickname" => "john", + "email" => "john@gmail.com", + "fullname" => "John Doe", + "bio" => "test", + "password" => "bear", + "confirm" => "bear" + } + + {:ok, user1} = TwitterAPI.register_user(data1) + + data2 = %{ + "nickname" => "lain", + "email" => "lain@wired.jp", + "fullname" => "lain iwakura", + "bio" => "@john test", + "password" => "bear", + "confirm" => "bear" + } + + {:ok, user2} = TwitterAPI.register_user(data2) + + expected_text = "@john test" + + assert user2.bio == expected_text + end + @moduletag skip: "needs 'registrations_open: false' in config" test "it registers a new user via invite token and returns the user." do {:ok, token} = UserInviteToken.create_token() -- cgit v1.2.3 From 8148943368510d1ec27889b91067d543ed4c2f10 Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Sun, 2 Dec 2018 22:08:53 +0300 Subject: Format files --- test/web/twitter_api/twitter_api_controller_test.exs | 4 +++- test/web/twitter_api/twitter_api_test.exs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index a1eb09a05..2cae8a071 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -961,7 +961,9 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do user = Repo.get!(User, user.id) assert user.name == "new name" - assert user.bio == "hi @#{user2.nickname}" + + assert user.bio == + "hi @#{user2.nickname}" assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index baeea5a9e..28230699f 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -280,7 +280,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user2} = TwitterAPI.register_user(data2) - expected_text = "@john test" + expected_text = + "@john test" assert user2.bio == expected_text end -- cgit v1.2.3 From 4b70e5eae93f34c1b98263a96d4e1380ef579ede Mon Sep 17 00:00:00 2001 From: Maxim Filippov Date: Mon, 3 Dec 2018 18:59:50 +0300 Subject: Parse bio for MastodonAPI --- test/web/mastodon_api/mastodon_api_controller_test.exs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 7042a6ace..098acb59f 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -1253,14 +1253,21 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do describe "updating credentials" do test "updates the user's bio", %{conn: conn} do user = insert(:user) + user2 = insert(:user) conn = conn |> assign(:user, user) - |> patch("/api/v1/accounts/update_credentials", %{"note" => "I drink #cofe"}) + |> patch("/api/v1/accounts/update_credentials", %{ + "note" => "I drink #cofe with @#{user2.nickname}" + }) assert user = json_response(conn, 200) - assert user["note"] == "I drink #cofe" + + assert user["note"] == + "I drink #cofe with @#{user2.nickname}" end test "updates the user's locking status", %{conn: conn} do -- cgit v1.2.3 From ec34de0c1fd58942c8ecefddef92696750b70420 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sun, 2 Dec 2018 16:58:38 +0300 Subject: WebSub fix test --- test/web/websub/websub_test.exs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'test/web') diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index da7bc9112..0b8bfda2d 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -10,6 +10,18 @@ defmodule Pleroma.Web.WebsubTest do alias Pleroma.Web.Websub.{WebsubServerSubscription, WebsubClientSubscription} import Pleroma.Factory alias Pleroma.Web.Router.Helpers + import Tesla.Mock + + setup do + mock fn + %{method: :get, url: "https://mastodon.social/users/lambadalambda.atom"} -> + %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")} + %{method: :post, url: "http://example.org/needs_refresh"} -> + %Tesla.Env{status: 200, body: ""} + end + + :ok + end test "a verification of a request that is accepted" do sub = insert(:websub_subscription) @@ -26,8 +38,8 @@ defmodule Pleroma.Web.WebsubTest do assert String.to_integer(seconds) > 0 {:ok, - %HTTPoison.Response{ - status_code: 200, + %Tesla.Env{ + status: 200, body: challenge }} end @@ -41,8 +53,8 @@ defmodule Pleroma.Web.WebsubTest do getter = fn _path, _headers, _options -> {:ok, - %HTTPoison.Response{ - status_code: 500, + %Tesla.Env{ + status: 500, body: "" }} end @@ -113,12 +125,7 @@ defmodule Pleroma.Web.WebsubTest do test "discovers the hub and canonical url" do topic = "https://mastodon.social/users/lambadalambda.atom" - getter = fn ^topic -> - doc = File.read!("test/fixtures/lambadalambda.atom") - {:ok, %{status_code: 200, body: doc}} - end - - {:ok, discovered} = Websub.gather_feed_data(topic, getter) + {:ok, discovered} = Websub.gather_feed_data(topic) expected = %{ "hub" => "https://mastodon.social/api/push", @@ -158,7 +165,7 @@ defmodule Pleroma.Web.WebsubTest do websub.id ) - {:ok, %{status_code: 202}} + {:ok, %{status: 202}} end task = Task.async(fn -> Websub.request_subscription(websub, poster) end) @@ -209,6 +216,7 @@ defmodule Pleroma.Web.WebsubTest do insert(:websub_client_subscription, %{ valid_until: NaiveDateTime.add(now, 2 * day), topic: "http://example.org/still_good", + hub: "http://example.org/still_good", state: "accepted" }) @@ -216,6 +224,7 @@ defmodule Pleroma.Web.WebsubTest do insert(:websub_client_subscription, %{ valid_until: NaiveDateTime.add(now, day - 100), topic: "http://example.org/needs_refresh", + hub: "http://example.org/needs_refresh", state: "accepted" }) -- cgit v1.2.3 From 87109482f336422186981c80eb3c3023637f09e8 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sun, 2 Dec 2018 17:08:36 +0300 Subject: status_code -> status --- test/web/websub/websub_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index 0b8bfda2d..f3d2da81a 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -184,7 +184,7 @@ defmodule Pleroma.Web.WebsubTest do websub = insert(:websub_client_subscription, %{hub: hub, topic: topic}) poster = fn ^hub, {:form, _data}, _headers -> - {:ok, %{status_code: 202}} + {:ok, %{status: 202}} end {:error, websub} = Websub.request_subscription(websub, poster, 1000) @@ -193,7 +193,7 @@ defmodule Pleroma.Web.WebsubTest do websub = insert(:websub_client_subscription, %{hub: hub, topic: topic}) poster = fn ^hub, {:form, _data}, _headers -> - {:ok, %{status_code: 400}} + {:ok, %{status: 400}} end {:error, websub} = Websub.request_subscription(websub, poster, 1000) -- cgit v1.2.3 From c508d41c349c3034211f41281cfe60c70a020575 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sun, 2 Dec 2018 18:17:26 +0300 Subject: add http requests mock --- test/web/salmon/salmon_test.exs | 5 +++++ test/web/websub/websub_test.exs | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'test/web') diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index 1b39b4b2d..3285c11f0 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -3,6 +3,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do alias Pleroma.Web.Salmon alias Pleroma.{Repo, Activity, User} import Pleroma.Factory + import Tesla.Mock @magickey "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwQhh-1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB" @@ -10,6 +11,10 @@ defmodule Pleroma.Web.Salmon.SalmonTest do @magickey_friendica "RSA.AMwa8FUs2fWEjX0xN7yRQgegQffhBpuKNC6fa5VNSVorFjGZhRrlPMn7TQOeihlc9lBz2OsHlIedbYn2uJ7yCs0.AQAB" + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "decodes a salmon" do {:ok, salmon} = File.read("test/fixtures/salmon.xml") {:ok, doc} = Salmon.decode_and_validate(@magickey, salmon) diff --git a/test/web/websub/websub_test.exs b/test/web/websub/websub_test.exs index f3d2da81a..47d1a88e1 100644 --- a/test/web/websub/websub_test.exs +++ b/test/web/websub/websub_test.exs @@ -13,13 +13,7 @@ defmodule Pleroma.Web.WebsubTest do import Tesla.Mock setup do - mock fn - %{method: :get, url: "https://mastodon.social/users/lambadalambda.atom"} -> - %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")} - %{method: :post, url: "http://example.org/needs_refresh"} -> - %Tesla.Env{status: 200, body: ""} - end - + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end -- cgit v1.2.3 From 6cfdc11e32faf84263e4c5d7b15f193ba1b832ae Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sun, 2 Dec 2018 22:05:28 +0300 Subject: update test --- test/web/ostatus/ostatus_test.exs | 6 ++++++ test/web/salmon/salmon_test.exs | 1 + test/web/web_finger/web_finger_test.exs | 6 ++++++ 3 files changed, 13 insertions(+) (limited to 'test/web') diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 32bf6691b..83525456b 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -5,6 +5,12 @@ defmodule Pleroma.Web.OStatusTest do alias Pleroma.{Object, Repo, User, Activity} import Pleroma.Factory import ExUnit.CaptureLog + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "don't insert create notes twice" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index 3285c11f0..23ccc038e 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -15,6 +15,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do mock(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end + test "decodes a salmon" do {:ok, salmon} = File.read("test/fixtures/salmon.xml") {:ok, doc} = Salmon.decode_and_validate(@magickey, salmon) diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs index 28d429565..32eff9b7c 100644 --- a/test/web/web_finger/web_finger_test.exs +++ b/test/web/web_finger/web_finger_test.exs @@ -2,6 +2,12 @@ defmodule Pleroma.Web.WebFingerTest do use Pleroma.DataCase alias Pleroma.Web.WebFinger import Pleroma.Factory + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end describe "host meta" do test "returns a link to the xml lrdd" do -- cgit v1.2.3 From 80bfdb4e7d3e339a1e47330c0de0fe7af9c00ab1 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Mon, 3 Dec 2018 18:53:22 +0300 Subject: update test --- test/web/activity_pub/activity_pub_test.exs | 6 ++++++ test/web/activity_pub/transmogrifier_test.exs | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 1d561d38d..90f11ecd4 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -7,6 +7,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do alias Pleroma.Builders.ActivityBuilder import Pleroma.Factory + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end describe "building a user from his ap id" do test "it returns a user" do diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index e74b8f9a1..faba80354 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -12,6 +12,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do import Pleroma.Factory alias Pleroma.Web.CommonAPI + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end + describe "handle_incoming" do test "it ignores an incoming notice if we already have it" do activity = insert(:note_activity) -- cgit v1.2.3 From 7ec64ac33f52d2f5072b56f2f8eb5e9ce498e00f Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Mon, 3 Dec 2018 21:37:55 +0300 Subject: update test --- test/web/http_sigs/http_sig_test.exs | 6 ++++++ test/web/mastodon_api/mastodon_api_controller_test.exs | 6 ++++++ test/web/mastodon_api/status_view_test.exs | 6 ++++++ test/web/ostatus/activity_representer_test.exs | 6 ++++++ test/web/ostatus/ostatus_controller_test.exs | 6 ++++++ 5 files changed, 30 insertions(+) (limited to 'test/web') diff --git a/test/web/http_sigs/http_sig_test.exs b/test/web/http_sigs/http_sig_test.exs index b2bf8d61b..2e189d583 100644 --- a/test/web/http_sigs/http_sig_test.exs +++ b/test/web/http_sigs/http_sig_test.exs @@ -4,6 +4,12 @@ defmodule Pleroma.Web.HTTPSignaturesTest do use Pleroma.DataCase alias Pleroma.Web.HTTPSignatures import Pleroma.Factory + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end @private_key hd(:public_key.pem_decode(File.read!("test/web/http_sigs/priv.key"))) |> :public_key.pem_entry_decode() diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 098acb59f..7cd98cde8 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -8,6 +8,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do import Pleroma.Factory import ExUnit.CaptureLog + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "the home timeline", %{conn: conn} do user = insert(:user) diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 31554a07d..9e69b3189 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -6,6 +6,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do alias Pleroma.Web.OStatus alias Pleroma.Web.CommonAPI import Pleroma.Factory + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "a note with null content" do note = insert(:note_activity) diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs index 8bf3bc775..a351510d8 100644 --- a/test/web/ostatus/activity_representer_test.exs +++ b/test/web/ostatus/activity_representer_test.exs @@ -7,6 +7,12 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do alias Pleroma.Web.OStatus import Pleroma.Factory + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "an external note activity" do incoming = File.read!("test/fixtures/mastodon-note-cw.xml") diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index e81adde68..6327a524e 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -4,6 +4,12 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do alias Pleroma.{User, Repo} alias Pleroma.Web.CommonAPI alias Pleroma.Web.OStatus.ActivityRepresenter + import Tesla.Mock + + setup do + mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end test "decodes a salmon", %{conn: conn} do user = insert(:user) -- cgit v1.2.3 From a9e4a975866c33553c477667c431187590329447 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 4 Dec 2018 14:01:39 +0300 Subject: update test --- test/web/activity_pub/transmogrifier_test.exs | 7 ++----- test/web/ostatus/ostatus_controller_test.exs | 5 ++--- test/web/ostatus/ostatus_test.exs | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) (limited to 'test/web') diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index faba80354..eeb0cb5cf 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -11,11 +11,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do import Pleroma.Factory alias Pleroma.Web.CommonAPI - - import Tesla.Mock - - setup do - mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index 6327a524e..411e89e94 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -4,10 +4,9 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do alias Pleroma.{User, Repo} alias Pleroma.Web.CommonAPI alias Pleroma.Web.OStatus.ActivityRepresenter - import Tesla.Mock - setup do - mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 83525456b..f3268e83d 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -5,10 +5,9 @@ defmodule Pleroma.Web.OStatusTest do alias Pleroma.{Object, Repo, User, Activity} import Pleroma.Factory import ExUnit.CaptureLog - import Tesla.Mock - setup do - mock(fn env -> apply(HttpRequestMock, :request, [env]) end) + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end -- cgit v1.2.3 From 5c6d47614dfd72566a91ac58223902e71ebdf1d3 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 4 Dec 2018 16:39:08 +0300 Subject: all tests passed --- test/web/activity_pub/activity_pub_controller_test.exs | 5 ++++- test/web/federator_test.exs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index 1c24b348c..414759110 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -4,7 +4,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do alias Pleroma.Web.ActivityPub.{UserView, ObjectView} alias Pleroma.{Repo, User} alias Pleroma.Activity - + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end describe "/relay" do test "with the relay active, it returns the relay user", %{conn: conn} do res = diff --git a/test/web/federator_test.exs b/test/web/federator_test.exs index 02e1ca76e..87bf73dbd 100644 --- a/test/web/federator_test.exs +++ b/test/web/federator_test.exs @@ -5,6 +5,11 @@ defmodule Pleroma.Web.FederatorTest do import Pleroma.Factory import Mock + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + :ok + end + test "enqueues an element according to priority" do queue = [%{item: 1, priority: 2}] -- cgit v1.2.3 From dd8aee332cf939f1a76f60a95b117ab90530178b Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 4 Dec 2018 17:48:55 +0300 Subject: formatting the code --- test/web/activity_pub/activity_pub_controller_test.exs | 2 ++ test/web/activity_pub/transmogrifier_test.exs | 1 + 2 files changed, 3 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index 414759110..980f43553 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -4,10 +4,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do alias Pleroma.Web.ActivityPub.{UserView, ObjectView} alias Pleroma.{Repo, User} alias Pleroma.Activity + setup_all do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok end + describe "/relay" do test "with the relay active, it returns the relay user", %{conn: conn} do res = diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index eeb0cb5cf..fa526a222 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -11,6 +11,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do import Pleroma.Factory alias Pleroma.Web.CommonAPI + setup_all do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) :ok -- cgit v1.2.3