Merge branch 'develop' into feature/polls-2-electric-boogalo
[akkoma] / test / support / http_request_mock.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule HttpRequestMock do
6 require Logger
7
8 def request(
9 %Tesla.Env{
10 url: url,
11 method: method,
12 headers: headers,
13 query: query,
14 body: body
15 } = _env
16 ) do
17 with {:ok, res} <- apply(__MODULE__, method, [url, query, body, headers]) do
18 res
19 else
20 {_, _r} = error ->
21 # Logger.warn(r)
22 error
23 end
24 end
25
26 # GET Requests
27 #
28 def get(url, query \\ [], body \\ [], headers \\ [])
29
30 def get("https://osada.macgirvin.com/channel/mike", _, _, _) do
31 {:ok,
32 %Tesla.Env{
33 status: 200,
34 body:
35 File.read!("test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json")
36 }}
37 end
38
39 def get("https://mastodon.social/users/emelie/statuses/101849165031453009", _, _, _) do
40 {:ok,
41 %Tesla.Env{
42 status: 200,
43 body: File.read!("test/fixtures/httpoison_mock/status.emelie.json")
44 }}
45 end
46
47 def get("https://mastodon.social/users/emelie", _, _, _) do
48 {:ok,
49 %Tesla.Env{
50 status: 200,
51 body: File.read!("test/fixtures/httpoison_mock/emelie.json")
52 }}
53 end
54
55 def get("https://mastodon.sdf.org/users/rinpatch", _, _, _) do
56 {:ok,
57 %Tesla.Env{
58 status: 200,
59 body: File.read!("test/fixtures/httpoison_mock/rinpatch.json")
60 }}
61 end
62
63 def get(
64 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie",
65 _,
66 _,
67 _
68 ) do
69 {:ok,
70 %Tesla.Env{
71 status: 200,
72 body: File.read!("test/fixtures/httpoison_mock/webfinger_emelie.json")
73 }}
74 end
75
76 def get("https://mastodon.social/users/emelie.atom", _, _, _) do
77 {:ok,
78 %Tesla.Env{
79 status: 200,
80 body: File.read!("test/fixtures/httpoison_mock/emelie.atom")
81 }}
82 end
83
84 def get(
85 "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
86 _,
87 _,
88 Accept: "application/xrd+xml,application/jrd+json"
89 ) do
90 {:ok,
91 %Tesla.Env{
92 status: 200,
93 body: File.read!("test/fixtures/httpoison_mock/mike@osada.macgirvin.com.json")
94 }}
95 end
96
97 def get(
98 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
99 _,
100 _,
101 Accept: "application/xrd+xml,application/jrd+json"
102 ) do
103 {:ok,
104 %Tesla.Env{
105 status: 200,
106 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml")
107 }}
108 end
109
110 def get("https://pawoo.net/users/pekorino.atom", _, _, _) do
111 {:ok,
112 %Tesla.Env{
113 status: 200,
114 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom")
115 }}
116 end
117
118 def get(
119 "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
120 _,
121 _,
122 Accept: "application/xrd+xml,application/jrd+json"
123 ) do
124 {:ok,
125 %Tesla.Env{
126 status: 200,
127 body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
128 }}
129 end
130
131 def get(
132 "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
133 _,
134 _,
135 _
136 ) do
137 {:ok,
138 %Tesla.Env{
139 status: 200,
140 body: File.read!("test/fixtures/httpoison_mock/atarifrosch_feed.xml")
141 }}
142 end
143
144 def get(
145 "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
146 _,
147 _,
148 Accept: "application/xrd+xml,application/jrd+json"
149 ) do
150 {:ok,
151 %Tesla.Env{
152 status: 200,
153 body: File.read!("test/fixtures/httpoison_mock/atarifrosch_webfinger.xml")
154 }}
155 end
156
157 def get("https://mamot.fr/users/Skruyb.atom", _, _, _) do
158 {:ok,
159 %Tesla.Env{
160 status: 200,
161 body: File.read!("test/fixtures/httpoison_mock/https___mamot.fr_users_Skruyb.atom")
162 }}
163 end
164
165 def get(
166 "https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
167 _,
168 _,
169 Accept: "application/xrd+xml,application/jrd+json"
170 ) do
171 {:ok,
172 %Tesla.Env{
173 status: 200,
174 body: File.read!("test/fixtures/httpoison_mock/skruyb@mamot.fr.atom")
175 }}
176 end
177
178 def get(
179 "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
180 _,
181 _,
182 Accept: "application/xrd+xml,application/jrd+json"
183 ) do
184 {:ok,
185 %Tesla.Env{
186 status: 200,
187 body: File.read!("test/fixtures/httpoison_mock/nonexistant@social.heldscal.la.xml")
188 }}
189 end
190
191 def get(
192 "https://squeet.me/xrd/?uri=lain@squeet.me",
193 _,
194 _,
195 Accept: "application/xrd+xml,application/jrd+json"
196 ) do
197 {:ok,
198 %Tesla.Env{
199 status: 200,
200 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
201 }}
202 end
203
204 def get(
205 "https://mst3k.interlinked.me/users/luciferMysticus",
206 _,
207 _,
208 Accept: "application/activity+json"
209 ) do
210 {:ok,
211 %Tesla.Env{
212 status: 200,
213 body: File.read!("test/fixtures/httpoison_mock/lucifermysticus.json")
214 }}
215 end
216
217 def get("https://prismo.news/@mxb", _, _, _) do
218 {:ok,
219 %Tesla.Env{
220 status: 200,
221 body: File.read!("test/fixtures/httpoison_mock/https___prismo.news__mxb.json")
222 }}
223 end
224
225 def get(
226 "https://hubzilla.example.org/channel/kaniini",
227 _,
228 _,
229 Accept: "application/activity+json"
230 ) do
231 {:ok,
232 %Tesla.Env{
233 status: 200,
234 body: File.read!("test/fixtures/httpoison_mock/kaniini@hubzilla.example.org.json")
235 }}
236 end
237
238 def get("https://niu.moe/users/rye", _, _, Accept: "application/activity+json") do
239 {:ok,
240 %Tesla.Env{
241 status: 200,
242 body: File.read!("test/fixtures/httpoison_mock/rye.json")
243 }}
244 end
245
246 def get("http://mastodon.example.org/users/admin/statuses/100787282858396771", _, _, _) do
247 {:ok,
248 %Tesla.Env{
249 status: 200,
250 body:
251 File.read!(
252 "test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
253 )
254 }}
255 end
256
257 def get("https://puckipedia.com/", _, _, Accept: "application/activity+json") do
258 {:ok,
259 %Tesla.Env{
260 status: 200,
261 body: File.read!("test/fixtures/httpoison_mock/puckipedia.com.json")
262 }}
263 end
264
265 def get("https://peertube.moe/accounts/7even", _, _, _) do
266 {:ok,
267 %Tesla.Env{
268 status: 200,
269 body: File.read!("test/fixtures/httpoison_mock/7even.json")
270 }}
271 end
272
273 def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
274 {:ok,
275 %Tesla.Env{
276 status: 200,
277 body: File.read!("test/fixtures/httpoison_mock/peertube.moe-vid.json")
278 }}
279 end
280
281 def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do
282 {:ok,
283 %Tesla.Env{
284 status: 200,
285 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-user.json")
286 }}
287 end
288
289 def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _, _) do
290 {:ok,
291 %Tesla.Env{
292 status: 200,
293 body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-article.json")
294 }}
295 end
296
297 def get("http://mastodon.example.org/users/admin", _, _, Accept: "application/activity+json") do
298 {:ok,
299 %Tesla.Env{
300 status: 200,
301 body: File.read!("test/fixtures/httpoison_mock/admin@mastdon.example.org.json")
302 }}
303 end
304
305 def get(
306 "http://mastodon.example.org/@admin/99541947525187367",
307 _,
308 _,
309 Accept: "application/activity+json"
310 ) do
311 {:ok,
312 %Tesla.Env{
313 status: 200,
314 body: File.read!("test/fixtures/mastodon-note-object.json")
315 }}
316 end
317
318 def get("https://shitposter.club/notice/7369654", _, _, _) do
319 {:ok,
320 %Tesla.Env{
321 status: 200,
322 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
323 }}
324 end
325
326 def get("https://mstdn.io/users/mayuutann", _, _, Accept: "application/activity+json") do
327 {:ok,
328 %Tesla.Env{
329 status: 200,
330 body: File.read!("test/fixtures/httpoison_mock/mayumayu.json")
331 }}
332 end
333
334 def get(
335 "https://mstdn.io/users/mayuutann/statuses/99568293732299394",
336 _,
337 _,
338 Accept: "application/activity+json"
339 ) do
340 {:ok,
341 %Tesla.Env{
342 status: 200,
343 body: File.read!("test/fixtures/httpoison_mock/mayumayupost.json")
344 }}
345 end
346
347 def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
348 {:ok,
349 %Tesla.Env{
350 status: 200,
351 body:
352 File.read!(
353 "test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain_feed.atom.xml"
354 )
355 }}
356 end
357
358 def get(url, _, _, Accept: "application/xrd+xml,application/jrd+json")
359 when url in [
360 "https://pleroma.soykaf.com/.well-known/webfinger?resource=acct:https://pleroma.soykaf.com/users/lain",
361 "https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/lain"
362 ] do
363 {:ok,
364 %Tesla.Env{
365 status: 200,
366 body: File.read!("test/fixtures/httpoison_mock/https___pleroma.soykaf.com_users_lain.xml")
367 }}
368 end
369
370 def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _, _, _) do
371 {:ok,
372 %Tesla.Env{
373 status: 200,
374 body:
375 File.read!(
376 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_user_timeline_1.atom.xml"
377 )
378 }}
379 end
380
381 def get(
382 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/1",
383 _,
384 _,
385 Accept: "application/xrd+xml,application/jrd+json"
386 ) do
387 {:ok,
388 %Tesla.Env{
389 status: 200,
390 body: File.read!("test/fixtures/httpoison_mock/https___shitposter.club_user_1.xml")
391 }}
392 end
393
394 def get("https://shitposter.club/notice/2827873", _, _, _) do
395 {:ok,
396 %Tesla.Env{
397 status: 200,
398 body:
399 File.read!("test/fixtures/httpoison_mock/https___shitposter.club_notice_2827873.html")
400 }}
401 end
402
403 def get("https://shitposter.club/api/statuses/show/2827873.atom", _, _, _) do
404 {:ok,
405 %Tesla.Env{
406 status: 200,
407 body:
408 File.read!(
409 "test/fixtures/httpoison_mock/https___shitposter.club_api_statuses_show_2827873.atom.xml"
410 )
411 }}
412 end
413
414 def get("https://testing.pleroma.lol/objects/b319022a-4946-44c5-9de9-34801f95507b", _, _, _) do
415 {:ok, %Tesla.Env{status: 200}}
416 end
417
418 def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _, _, _) do
419 {:ok,
420 %Tesla.Env{
421 status: 200,
422 body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom")
423 }}
424 end
425
426 def get(
427 "https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381",
428 _,
429 _,
430 Accept: "application/xrd+xml,application/jrd+json"
431 ) do
432 {:ok,
433 %Tesla.Env{
434 status: 200,
435 body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml")
436 }}
437 end
438
439 def get("http://shitposter.club/.well-known/host-meta", _, _, _) do
440 {:ok,
441 %Tesla.Env{
442 status: 200,
443 body: File.read!("test/fixtures/httpoison_mock/shitposter.club_host_meta")
444 }}
445 end
446
447 def get("https://shitposter.club/api/statuses/show/7369654.atom", _, _, _) do
448 {:ok,
449 %Tesla.Env{
450 status: 200,
451 body: File.read!("test/fixtures/httpoison_mock/7369654.atom")
452 }}
453 end
454
455 def get("https://shitposter.club/notice/4027863", _, _, _) do
456 {:ok,
457 %Tesla.Env{
458 status: 200,
459 body: File.read!("test/fixtures/httpoison_mock/7369654.html")
460 }}
461 end
462
463 def get("https://social.sakamoto.gq/users/eal/feed.atom", _, _, _) do
464 {:ok,
465 %Tesla.Env{
466 status: 200,
467 body: File.read!("test/fixtures/httpoison_mock/sakamoto_eal_feed.atom")
468 }}
469 end
470
471 def get("http://social.sakamoto.gq/.well-known/host-meta", _, _, _) do
472 {:ok,
473 %Tesla.Env{
474 status: 200,
475 body: File.read!("test/fixtures/httpoison_mock/social.sakamoto.gq_host_meta")
476 }}
477 end
478
479 def get(
480 "https://social.sakamoto.gq/.well-known/webfinger?resource=https://social.sakamoto.gq/users/eal",
481 _,
482 _,
483 Accept: "application/xrd+xml,application/jrd+json"
484 ) do
485 {:ok,
486 %Tesla.Env{
487 status: 200,
488 body: File.read!("test/fixtures/httpoison_mock/eal_sakamoto.xml")
489 }}
490 end
491
492 def get(
493 "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056",
494 _,
495 _,
496 Accept: "application/atom+xml"
497 ) do
498 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")}}
499 end
500
501 def get("http://mastodon.social/.well-known/host-meta", _, _, _) do
502 {:ok,
503 %Tesla.Env{
504 status: 200,
505 body: File.read!("test/fixtures/httpoison_mock/mastodon.social_host_meta")
506 }}
507 end
508
509 def get(
510 "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/lambadalambda",
511 _,
512 _,
513 Accept: "application/xrd+xml,application/jrd+json"
514 ) do
515 {:ok,
516 %Tesla.Env{
517 status: 200,
518 body:
519 File.read!(
520 "test/fixtures/httpoison_mock/https___mastodon.social_users_lambadalambda.xml"
521 )
522 }}
523 end
524
525 def get("http://gs.example.org/.well-known/host-meta", _, _, _) do
526 {:ok,
527 %Tesla.Env{
528 status: 200,
529 body: File.read!("test/fixtures/httpoison_mock/gs.example.org_host_meta")
530 }}
531 end
532
533 def get(
534 "http://gs.example.org/.well-known/webfinger?resource=http://gs.example.org:4040/index.php/user/1",
535 _,
536 _,
537 Accept: "application/xrd+xml,application/jrd+json"
538 ) do
539 {:ok,
540 %Tesla.Env{
541 status: 200,
542 body:
543 File.read!(
544 "test/fixtures/httpoison_mock/http___gs.example.org_4040_index.php_user_1.xml"
545 )
546 }}
547 end
548
549 def get("http://gs.example.org/index.php/api/statuses/user_timeline/1.atom", _, _, _) do
550 {:ok,
551 %Tesla.Env{
552 status: 200,
553 body:
554 File.read!(
555 "test/fixtures/httpoison_mock/http__gs.example.org_index.php_api_statuses_user_timeline_1.atom.xml"
556 )
557 }}
558 end
559
560 def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _, _, _) do
561 {:ok,
562 %Tesla.Env{
563 status: 200,
564 body:
565 File.read!(
566 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_29191.atom.xml"
567 )
568 }}
569 end
570
571 def get("http://squeet.me/.well-known/host-meta", _, _, _) do
572 {:ok,
573 %Tesla.Env{status: 200, body: File.read!("test/fixtures/httpoison_mock/squeet.me_host_meta")}}
574 end
575
576 def get(
577 "https://squeet.me/xrd?uri=lain@squeet.me",
578 _,
579 _,
580 Accept: "application/xrd+xml,application/jrd+json"
581 ) do
582 {:ok,
583 %Tesla.Env{
584 status: 200,
585 body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
586 }}
587 end
588
589 def get(
590 "https://social.heldscal.la/.well-known/webfinger?resource=shp@social.heldscal.la",
591 _,
592 _,
593 Accept: "application/xrd+xml,application/jrd+json"
594 ) do
595 {:ok,
596 %Tesla.Env{
597 status: 200,
598 body: File.read!("test/fixtures/httpoison_mock/shp@social.heldscal.la.xml")
599 }}
600 end
601
602 def get("http://framatube.org/.well-known/host-meta", _, _, _) do
603 {:ok,
604 %Tesla.Env{
605 status: 200,
606 body: File.read!("test/fixtures/httpoison_mock/framatube.org_host_meta")
607 }}
608 end
609
610 def get(
611 "http://framatube.org/main/xrd?uri=framasoft@framatube.org",
612 _,
613 _,
614 Accept: "application/xrd+xml,application/jrd+json"
615 ) do
616 {:ok,
617 %Tesla.Env{
618 status: 200,
619 headers: [{"content-type", "application/json"}],
620 body: File.read!("test/fixtures/httpoison_mock/framasoft@framatube.org.json")
621 }}
622 end
623
624 def get("http://gnusocial.de/.well-known/host-meta", _, _, _) do
625 {:ok,
626 %Tesla.Env{
627 status: 200,
628 body: File.read!("test/fixtures/httpoison_mock/gnusocial.de_host_meta")
629 }}
630 end
631
632 def get(
633 "http://gnusocial.de/main/xrd?uri=winterdienst@gnusocial.de",
634 _,
635 _,
636 Accept: "application/xrd+xml,application/jrd+json"
637 ) do
638 {:ok,
639 %Tesla.Env{
640 status: 200,
641 body: File.read!("test/fixtures/httpoison_mock/winterdienst_webfinger.json")
642 }}
643 end
644
645 def get("http://status.alpicola.com/.well-known/host-meta", _, _, _) do
646 {:ok,
647 %Tesla.Env{
648 status: 200,
649 body: File.read!("test/fixtures/httpoison_mock/status.alpicola.com_host_meta")
650 }}
651 end
652
653 def get("http://macgirvin.com/.well-known/host-meta", _, _, _) do
654 {:ok,
655 %Tesla.Env{
656 status: 200,
657 body: File.read!("test/fixtures/httpoison_mock/macgirvin.com_host_meta")
658 }}
659 end
660
661 def get("http://gerzilla.de/.well-known/host-meta", _, _, _) do
662 {:ok,
663 %Tesla.Env{
664 status: 200,
665 body: File.read!("test/fixtures/httpoison_mock/gerzilla.de_host_meta")
666 }}
667 end
668
669 def get(
670 "https://gerzilla.de/xrd/?uri=kaniini@gerzilla.de",
671 _,
672 _,
673 Accept: "application/xrd+xml,application/jrd+json"
674 ) do
675 {:ok,
676 %Tesla.Env{
677 status: 200,
678 headers: [{"content-type", "application/json"}],
679 body: File.read!("test/fixtures/httpoison_mock/kaniini@gerzilla.de.json")
680 }}
681 end
682
683 def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _, _, _) do
684 {:ok,
685 %Tesla.Env{
686 status: 200,
687 body:
688 File.read!(
689 "test/fixtures/httpoison_mock/https___social.heldscal.la_api_statuses_user_timeline_23211.atom.xml"
690 )
691 }}
692 end
693
694 def get(
695 "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/23211",
696 _,
697 _,
698 _
699 ) do
700 {:ok,
701 %Tesla.Env{
702 status: 200,
703 body: File.read!("test/fixtures/httpoison_mock/https___social.heldscal.la_user_23211.xml")
704 }}
705 end
706
707 def get("http://social.heldscal.la/.well-known/host-meta", _, _, _) do
708 {:ok,
709 %Tesla.Env{
710 status: 200,
711 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
712 }}
713 end
714
715 def get("https://social.heldscal.la/.well-known/host-meta", _, _, _) do
716 {:ok,
717 %Tesla.Env{
718 status: 200,
719 body: File.read!("test/fixtures/httpoison_mock/social.heldscal.la_host_meta")
720 }}
721 end
722
723 def get("https://mastodon.social/users/lambadalambda.atom", _, _, _) do
724 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.atom")}}
725 end
726
727 def get("https://mastodon.social/users/lambadalambda", _, _, _) do
728 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/lambadalambda.json")}}
729 end
730
731 def get("https://social.heldscal.la/user/23211", _, _, Accept: "application/activity+json") do
732 {:ok, Tesla.Mock.json(%{"id" => "https://social.heldscal.la/user/23211"}, status: 200)}
733 end
734
735 def get("http://example.com/ogp", _, _, _) do
736 {:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}}
737 end
738
739 def get("http://example.com/ogp-missing-data", _, _, _) do
740 {:ok,
741 %Tesla.Env{
742 status: 200,
743 body: File.read!("test/fixtures/rich_media/ogp-missing-data.html")
744 }}
745 end
746
747 def get("http://example.com/malformed", _, _, _) do
748 {:ok,
749 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/malformed-data.html")}}
750 end
751
752 def get("http://example.com/empty", _, _, _) do
753 {:ok, %Tesla.Env{status: 200, body: "hello"}}
754 end
755
756 def get("http://404.site" <> _, _, _, _) do
757 {:ok,
758 %Tesla.Env{
759 status: 404,
760 body: ""
761 }}
762 end
763
764 def get(url, query, body, headers) do
765 {:error,
766 "Not implemented the mock response for get #{inspect(url)}, #{query}, #{inspect(body)}, #{
767 inspect(headers)
768 }"}
769 end
770
771 # POST Requests
772 #
773
774 def post(url, query \\ [], body \\ [], headers \\ [])
775
776 def post("http://example.org/needs_refresh", _, _, _) do
777 {:ok,
778 %Tesla.Env{
779 status: 200,
780 body: ""
781 }}
782 end
783
784 def post("http://200.site" <> _, _, _, _) do
785 {:ok,
786 %Tesla.Env{
787 status: 200,
788 body: ""
789 }}
790 end
791
792 def post("http://connrefused.site" <> _, _, _, _) do
793 {:error, :connrefused}
794 end
795
796 def post("http://404.site" <> _, _, _, _) do
797 {:ok,
798 %Tesla.Env{
799 status: 404,
800 body: ""
801 }}
802 end
803
804 def post(url, _query, _body, _headers) do
805 {:error, "Not implemented the mock response for post #{inspect(url)}"}
806 end
807 end