From 5c6d47614dfd72566a91ac58223902e71ebdf1d3 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 4 Dec 2018 16:39:08 +0300 Subject: [PATCH] all tests passed --- test/support/http_request_mock.ex | 29 +++++++++++++------ .../activity_pub_controller_test.exs | 5 +++- test/web/federator_test.exs | 5 ++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index 80b84d591..c1b1c8589 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -14,7 +14,7 @@ defmodule HttpRequestMock do res else {_, r} = error -> - Logger.warn(r) + #Logger.warn(r) error end end @@ -22,6 +22,25 @@ defmodule HttpRequestMock do # GET Requests # def get(url, query \\ [], body \\ [], headers \\ []) + + def get("https://osada.macgirvin.com/channel/mike", _, _, _) do + {:ok, + %Tesla.Env{ + status: 200, + body: File.read!( + "test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json" + ) + }} + end + + def get("https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do + {:ok, + %Tesla.Env{ + status: 200, + body: File.read!("test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json") + }} + end + def get("https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do {:ok, @@ -90,14 +109,6 @@ defmodule HttpRequestMock do }} end - def get("http://gs.example.org:4040/index.php/user/1", _, _, Accept: "application/activity+json") do - {:ok, - %Tesla.Env{ - status: 200, - body: "{\"id\": 1}" - }} - end - def get("https://squeet.me/xrd/?uri=lain@squeet.me", _, _, Accept: "application/xrd+xml,application/jrd+json" ) do 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}]