projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'MAIN/develop' into feature/jobs
[akkoma]
/
test
/
support
/
http_request_mock.ex
diff --git
a/test/support/http_request_mock.ex
b/test/support/http_request_mock.ex
index c1b1c858910f1595e09a71ce8e0dbcf76c41c9d3..3043d2be6953b31686f04ceb2f5ebbf920829c37 100644
(file)
--- a/
test/support/http_request_mock.ex
+++ b/
test/support/http_request_mock.ex
@@
-1,3
+1,7
@@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule HttpRequestMock do
require Logger
defmodule HttpRequestMock do
require Logger
@@
-13,8
+17,8
@@
defmodule HttpRequestMock do
with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
res
else
with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
res
else
- {_, r} = error ->
- #Logger.warn(r)
+ {_,
_
r} = error ->
+ #
Logger.warn(r)
error
end
end
error
end
end
@@
-27,13
+31,17
@@
defmodule HttpRequestMock do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
- body: File.read!(
- "test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json"
- )
+ body:
+ File.read!("test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json")
}}
end
}}
end
- def get("https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+ 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,
{:ok,
%Tesla.Env{
status: 200,
@@
-41,8
+49,12
@@
defmodule HttpRequestMock do
}}
end
}}
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
+ 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,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-58,8
+70,12
@@
defmodule HttpRequestMock do
}}
end
}}
end
- def get("https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
- _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+ def get(
+ "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
+ _,
+ _,
+ Accept: "application/xrd+xml,application/jrd+json"
+ ) do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-67,7
+83,12
@@
defmodule HttpRequestMock do
}}
end
}}
end
- def get("https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom", _, _, _) do
+ def get(
+ "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
+ _,
+ _,
+ _
+ ) do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-75,8
+96,12
@@
defmodule HttpRequestMock do
}}
end
}}
end
- def get("https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
- _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+ def get(
+ "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
+ _,
+ _,
+ Accept: "application/xrd+xml,application/jrd+json"
+ ) do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-92,8
+117,12
@@
defmodule HttpRequestMock do
}}
end
}}
end
- def get("https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
- _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+ def get(
+ "https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
+ _,
+ _,
+ Accept: "application/xrd+xml,application/jrd+json"
+ ) do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-101,7
+130,12
@@
defmodule HttpRequestMock do
}}
end
}}
end
- def get("https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+ def get(
+ "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
+ _,
+ _,
+ Accept: "application/xrd+xml,application/jrd+json"
+ ) do
{:ok,
%Tesla.Env{
status: 200,
{:ok,
%Tesla.Env{
status: 200,
@@
-619,6
+653,14
@@
defmodule HttpRequestMock do
{:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
end
{:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
end
+ def get("http://example.com/ogp", _, _, _) do
+ {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
+ end
+
+ def get("http://example.com/empty", _, _, _) do
+ {:ok, %Tesla.Env{status: 200, body: "hello"}}
+ end
+
def get(url, query, body, headers) do
{:error,
"Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
def get(url, query, body, headers) do
{:error,
"Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{