Add invisible tags to TwAPI output.
[akkoma] / test / support / httpoison_mock.ex
1 defmodule HTTPoisonMock do
2 alias HTTPoison.Response
3
4 def get(url, body \\ [], headers \\ [])
5
6 def get("https://social.heldscal.la/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "nonexistant@social.heldscal.la"]]) do
7 {:ok, %Response{
8 status_code: 500,
9 body: File.read!("test/fixtures/httpoison_mock/nonexistant@social.heldscal.la.xml")
10 }}
11 end
12
13 def get("https://social.heldscal.la/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "shp@social.heldscal.la"]]) do
14 {:ok, %Response{
15 status_code: 200,
16 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
17 }}
18 end
19
20 def get("https://social.heldscal.la/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://social.heldscal.la/user/23211"]]) do
21 {:ok, %Response{
22 status_code: 200,
23 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
24 }}
25 end
26
27 def get("https://social.heldscal.la/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://social.heldscal.la/user/29191"]]) do
28 {:ok, %Response{
29 status_code: 200,
30 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml")
31 }}
32 end
33
34 def get("https://mastodon.social/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://mastodon.social/users/lambadalambda"]]) do
35 {:ok, %Response{
36 status_code: 200,
37 body: File.read!("test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml")
38 }}
39 end
40
41 def get("https://shitposter.club/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://shitposter.club/user/1"]]) do
42 {:ok, %Response{
43 status_code: 200,
44 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
45 }}
46 end
47
48 def get("http://gs.example.org/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "http://gs.example.org:4040/index.php/user/1"], follow_redirect: true]) do
49 {:ok, %Response{
50 status_code: 200,
51 body: File.read!("test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml")
52 }}
53 end
54
55 def get("https://pleroma.soykaf.com/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://pleroma.soykaf.com/users/lain"]]) do
56 {:ok, %Response{
57 status_code: 200,
58 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
59 }}
60 end
61
62 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _body, _headers) do
63 {:ok, %Response{
64 status_code: 200,
65 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml")
66 }}
67 end
68
69 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _body, _headers) do
70 {:ok, %Response{
71 status_code: 200,
72 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml")
73 }}
74 end
75
76 def get("https://mastodon.social/users/lambadalambda.atom", _body, _headers) do
77 {:ok, %Response{
78 status_code: 200,
79 body: File.read!("test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.atom")
80 }}
81 end
82
83 def get("https://pleroma.soykaf.com/users/lain/feed.atom", _body, _headers) do
84 {:ok, %Response{
85 status_code: 200,
86 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml")
87 }}
88 end
89
90 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _body, _headers) do
91 {:ok, %Response{
92 status_code: 200,
93 body: File.read!("test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml")
94 }}
95 end
96
97 def get("https://shitposter.club/notice/2827873", _body, _headers) do
98 {:ok, %Response{
99 status_code: 200,
100 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
101 }}
102 end
103
104 def get("https://shitposter.club/api/statuses/show/2827873.atom", _body, _headers) do
105 {:ok, %Response{
106 status_code: 200,
107 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml")
108 }}
109 end
110
111 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _body, _headers) do
112 {:ok, %Response{
113 status_code: 200,
114 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml")
115 }}
116 end
117
118 def post("https://social.heldscal.la/main/push/hub", {:form, data}, ["Content-type": "application/x-www-form-urlencoded"]) do
119 {:ok, %Response{
120 status_code: 202
121 }}
122 end
123
124 def get("https://pawoo.net/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://pawoo.net/users/pekorino"]]) do
125 {:ok, %Response{
126 status_code: 200,
127 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
128 }}
129 end
130
131 def get("https://pawoo.net/users/pekorino.atom", _, _) do
132 {:ok, %Response{
133 status_code: 200,
134 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom")
135 }}
136 end
137
138 def get("https://mamot.fr/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://mamot.fr/users/Skruyb"]]) do
139 {:ok, %Response{
140 status_code: 200,
141 body: File.read!("test/fixtures/httpoison_mock/skruyb@mamot.fr.atom")
142 }}
143 end
144
145 def get("https://mamot.fr/users/Skruyb.atom", _, _) do
146 {:ok, %Response{
147 status_code: 200,
148 body: File.read!("test/fixtures/httpoison_mock/https___mamot.fr_users_Skruyb.atom")
149 }}
150 end
151
152 def get(url, body, headers) do
153 {:error, "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{inspect(headers)}"}
154 end
155
156 def post(url, body, headers) do
157 {:error, "Not implemented the mock response for post #{inspect(url)}"}
158 end
159 end