Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
a9e4a975
Commit
a9e4a975
authored
Dec 04, 2018
by
Maksim
Browse files
update test
parent
7ec64ac3
Changes
7
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/http/http.ex
View file @
a9e4a975
...
...
@@ -18,6 +18,7 @@ def request(method, url, body \\ "", headers \\ [], options \\ []) do
|>
(
&
Tesla
.
request
(
Connection
.
new
(),
&1
))
.
()
end
defp
process_sni_options
(
options
,
nil
),
do
:
options
defp
process_sni_options
(
options
,
url
)
do
uri
=
URI
.
parse
(
url
)
host
=
uri
.
host
|>
to_charlist
()
...
...
test/formatter_test.exs
View file @
a9e4a975
...
...
@@ -4,6 +4,10 @@ defmodule Pleroma.FormatterTest do
use
Pleroma
.
DataCase
import
Pleroma
.
Factory
setup_all
do
Tesla
.
Mock
.
mock_global
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
:ok
end
describe
".add_hashtag_links"
do
test
"turns hashtags into links"
do
...
...
test/support/http_request_mock.ex
View file @
a9e4a975
...
...
@@ -22,6 +22,73 @@ def request(
# GET Requests
#
def
get
(
url
,
query
\\
[],
body
\\
[],
headers
\\
[])
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
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/https___social.heldscal.la_user_29191.xml"
)
}}
end
def
get
(
"https://pawoo.net/users/pekorino.atom"
,
_
,
_
,
_
)
do
{
:ok
,
%
Tesla
.
Env
{
status:
200
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom"
)
}}
end
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
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml"
)
}}
end
def
get
(
"https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom"
,
_
,
_
,
_
)
do
{
:ok
,
%
Tesla
.
Env
{
status:
200
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/atarifrosch_feed.xml"
)
}}
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
{
:ok
,
%
Tesla
.
Env
{
status:
200
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/atarifrosch_webfinger.xml"
)
}}
end
def
get
(
"https://mamot.fr/users/Skruyb.atom"
,
_
,
_
,
_
)
do
{
:ok
,
%
Tesla
.
Env
{
status:
200
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/https___mamot.fr_users_Skruyb.atom"
)
}}
end
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
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/skruyb@mamot.fr.atom"
)
}}
end
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
,
body:
File
.
read!
(
"test/fixtures/httpoison_mock/nonexistant@social.heldscal.la.xml"
)
}}
end
def
get
(
"http://gs.example.org:4040/index.php/user/1"
,
_
,
_
,
Accept:
"application/activity+json"
)
do
{
:ok
,
...
...
test/user_test.exs
View file @
a9e4a975
...
...
@@ -9,6 +9,11 @@ defmodule Pleroma.UserTest do
import
Pleroma
.
Factory
import
Ecto
.
Query
setup_all
do
Tesla
.
Mock
.
mock_global
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
:ok
end
test
"ap_id returns the activity pub id for the user"
do
user
=
UserBuilder
.
build
()
...
...
test/web/activity_pub/transmogrifier_test.exs
View file @
a9e4a975
...
...
@@ -11,11 +11,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
import
Pleroma
.
Factory
alias
Pleroma
.
Web
.
CommonAPI
import
Tesla
.
Mock
setup
do
mock
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
setup_all
do
Tesla
.
Mock
.
mock_global
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
:ok
end
...
...
test/web/ostatus/ostatus_controller_test.exs
View file @
a9e4a975
...
...
@@ -4,10 +4,9 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
alias
Pleroma
.
{
User
,
Repo
}
alias
Pleroma
.
Web
.
CommonAPI
alias
Pleroma
.
Web
.
OStatus
.
ActivityRepresenter
import
Tesla
.
Mock
setup
do
mock
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
setup
_all
do
Tesla
.
Mock
.
mock_global
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
:ok
end
...
...
test/web/ostatus/ostatus_test.exs
View file @
a9e4a975
...
...
@@ -5,10 +5,9 @@ defmodule Pleroma.Web.OStatusTest do
alias
Pleroma
.
{
Object
,
Repo
,
User
,
Activity
}
import
Pleroma
.
Factory
import
ExUnit
.
CaptureLog
import
Tesla
.
Mock
setup
do
mock
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
setup
_all
do
Tesla
.
Mock
.
mock_global
(
fn
env
->
apply
(
HttpRequestMock
,
:request
,
[
env
])
end
)
:ok
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment