1 defmodule HttpRequestMock do
13 with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
24 def get(url, query \\ [], body \\ [], headers \\ [])
26 def get("https://prismo.news/@mxb", _, _, _) do
30 body: File.read!("test/fixtures/httpoison_mock/https___prismo.news__mxb.json")
34 def get("https://hubzilla.example.org/channel/kaniini",
35 _, _, [Accept: "application/activity+json"]) do
39 body: File.read!("test/fixtures/httpoison_mock/kaniini@hubzilla.example.org.json")
43 def get("https://niu.moe/users/rye", _, _, [Accept: "application/activity+json"]) do
47 body: File.read!("test/fixtures/httpoison_mock/rye.json")
51 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
56 "test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
61 def get("https://puckipedia.com/", _, _, [Accept: "application/activity+json"]) do
65 body: File.read!("test/fixtures/httpoison_mock/puckipedia.com.json")
70 def get("https://peertube.moe/accounts/7even", _, _, _) do
74 body: File.read!("test/fixtures/httpoison_mock/7even.json")
78 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
82 body: File.read!("test/fixtures/httpoison_mock/peertube.moe-vid.json")
86 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
90 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-user.json")
94 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
98 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-article.json")
103 def get("http://mastodon.example.org/users/admin", _, _, [Accept: "application/activity+json"]) do
107 body: File.read!("test/fixtures/httpoison_mock/admin@mastdon.example.org.json")
111 def get("http://mastodon.example.org/@admin/99541947525187367",
112 _, _, [Accept: "application/activity+json"]) do
116 body: File.read!("test/fixtures/mastodon-note-object.json")
120 def get("https://shitposter.club/notice/7369654", _, _, _) do
124 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
128 def get("https://mstdn.io/users/mayuutann", _, _, [Accept: "application/activity+json"]) do
132 body: File.read!("test/fixtures/httpoison_mock/mayumayu.json")
136 def get("https://mstdn.io/users/mayuutann/statuses/99568293732299394",
137 _, _, [Accept: "application/activity+json"]) do
141 body: File.read!("test/fixtures/httpoison_mock/mayumayupost.json")
146 def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
152 "test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
157 def get(url, _, _, Accept: "application/xrd+xml,application/jrd+json")
159 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
160 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
165 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
169 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
175 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
181 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
184 Accept: "application/xrd+xml,application/jrd+json"
189 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
193 def get("https://shitposter.club/notice/2827873", _, _, _) do
198 File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
202 def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
208 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
213 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
214 {:ok, %Tesla.Env{status: 200}}
217 def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
221 body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom")
226 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
229 Accept: "application/xrd+xml,application/jrd+json"
234 body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml")
238 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
242 body: File.read!("test/fixtures/httpoison_mock/shitposter.club_host_meta")
246 def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
250 body: File.read!("test/fixtures/httpoison_mock/7369654.atom")
254 def get("https://shitposter.club/notice/4027863", _, _, _) do
258 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
262 def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
266 body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom")
270 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
274 body: File.read!("test/fixtures/httpoison_mock/social.sakamoto.gq_host_meta")
279 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
282 Accept: "application/xrd+xml,application/jrd+json"
287 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
291 def get("https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056", _, _,
292 Accept: "application/atom+xml"
294 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")}}
297 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
301 body: File.read!("test/fixtures/httpoison_mock/mastodon.social_host_meta")
306 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
309 Accept: "application/xrd+xml,application/jrd+json"
316 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
321 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
325 body: File.read!("test/fixtures/httpoison_mock/gs.example.org_host_meta")
330 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
333 Accept: "application/xrd+xml,application/jrd+json"
340 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
345 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
351 "test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
356 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
362 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
367 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
369 %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/squeet.me_host_meta")}}
372 def get("https://squeet.me/xrd?uri=lain@squeet.me", _, _,
373 Accept: "application/xrd+xml,application/jrd+json"
378 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
383 "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
386 Accept: "application/xrd+xml,application/jrd+json"
391 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
395 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
399 body: File.read!("test/fixtures/httpoison_mock/framatube.org_host_meta")
403 def get("http://framatube.org/main/xrd?uri=framasoft@framatube.org", _, _,
404 Accept: "application/xrd+xml,application/jrd+json"
409 headers: [{"content-type", "application/json"}],
410 body: File.read!("test/fixtures/httpoison_mock/framasoft@framatube.org.json")
414 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
418 body: File.read!("test/fixtures/httpoison_mock/gnusocial.de_host_meta")
422 def get("http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de", _, _,
423 Accept: "application/xrd+xml,application/jrd+json"
428 body: File.read!("test/fixtures/httpoison_mock/winterdienst_webfinger.json")
432 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
436 body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta")
440 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
444 body: File.read!("test/fixtures/httpoison_mock/macgirvin.com_host_meta")
448 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
452 body: File.read!("test/fixtures/httpoison_mock/gerzilla.de_host_meta")
456 def get("https://gerzilla.de/xrd/?uri=kaniini@gerzilla.de", _, _,
457 Accept: "application/xrd+xml,application/jrd+json"
462 headers: [{"content-type", "application/json"}],
463 body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
467 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
473 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
479 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
487 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
491 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
495 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
499 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
503 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
507 def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
508 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
511 def get("https://social.heldscal.la/user/23211", _, _, Accept: "application/activity+json") do
512 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
515 def get(url, query, body, headers) do
517 "Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
525 def post(url, query \\ [], body \\ [], headers \\ [])
527 def post("http://example.org/needs_refresh", _, _, _) do
535 def post(url, _query, _body, _headers) do
536 {:error, "Not implemented the mock response for post #{inspect(url)}"}