Add anonymous and remote participations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
@@ -9,28 +9,31 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Addok
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
"#{Config.instance_name()} #{Config.instance_hostname()} - Mobilizon #{
|
||||
Mix.Project.config()[:version]
|
||||
}"}
|
||||
]
|
||||
setup do
|
||||
# Config.instance_user_agent/0 makes database calls so because of ownership connection
|
||||
# we need to define it like this instead of a constant
|
||||
# See https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html
|
||||
{:ok,
|
||||
httpoison_headers: [
|
||||
{"User-Agent", Config.instance_user_agent()}
|
||||
]}
|
||||
end
|
||||
|
||||
@endpoint get_in(Application.get_env(:mobilizon, Addok), [:endpoint])
|
||||
@fake_endpoint "https://domain.tld"
|
||||
|
||||
describe "search address" do
|
||||
test "produces a valid search address" do
|
||||
test "produces a valid search address", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
Addok.search("10 Rue Jangot")
|
||||
|
||||
assert_called(
|
||||
HTTPoison.get("#{@endpoint}/search/?q=10%20Rue%20Jangot&limit=10", @httpoison_headers)
|
||||
HTTPoison.get("#{@endpoint}/search/?q=10%20Rue%20Jangot&limit=10", httpoison_headers)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
test "produces a valid search address with options" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
Addok.search("10 Rue Jangot",
|
||||
endpoint: @fake_endpoint,
|
||||
@@ -41,7 +44,7 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"#{@fake_endpoint}/search/?q=10%20Rue%20Jangot&limit=5&lat=49&lon=12",
|
||||
@httpoison_headers
|
||||
httpoison_headers
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
@@ -9,12 +9,15 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.MapQuest
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
"#{Config.instance_name()} #{Config.instance_hostname()} - Mobilizon #{
|
||||
Mix.Project.config()[:version]
|
||||
}"}
|
||||
]
|
||||
setup do
|
||||
# Config.instance_user_agent/0 makes database calls so because of ownership connection
|
||||
# we need to define it like this instead of a constant
|
||||
# See https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html
|
||||
{:ok,
|
||||
httpoison_headers: [
|
||||
{"User-Agent", Config.instance_user_agent()}
|
||||
]}
|
||||
end
|
||||
|
||||
describe "search address" do
|
||||
test "without API Key triggers an error" do
|
||||
@@ -23,7 +26,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
end
|
||||
end
|
||||
|
||||
test "produces a valid search address with options" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
{:ok,
|
||||
@@ -41,7 +44,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"https://open.mapquestapi.com/geocoding/v1/address?key=toto&location=10%20Rue%20Jangot&maxResults=5",
|
||||
@httpoison_headers
|
||||
httpoison_headers
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
import Mock
|
||||
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Nominatim
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
"#{Config.instance_name()} #{Config.instance_hostname()} - Mobilizon #{
|
||||
Mix.Project.config()[:version]
|
||||
}"}
|
||||
]
|
||||
setup do
|
||||
# Config.instance_user_agent/0 makes database calls so because of ownership connection
|
||||
# we need to define it like this instead of a constant
|
||||
# See https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html
|
||||
{:ok,
|
||||
httpoison_headers: [
|
||||
{"User-Agent", Config.instance_user_agent()}
|
||||
]}
|
||||
end
|
||||
|
||||
describe "search address" do
|
||||
test "produces a valid search address with options" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
{:ok, %HTTPoison.Response{status_code: 200, body: "[]"}}
|
||||
@@ -30,7 +31,7 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"https://nominatim.openstreetmap.org/search?format=geocodejson&q=10%20Rue%20Jangot&limit=5&accept-language=fr&addressdetails=1&namedetails=1",
|
||||
@httpoison_headers
|
||||
httpoison_headers
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
@@ -9,15 +9,18 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Photon
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
"#{Config.instance_name()} #{Config.instance_hostname()} - Mobilizon #{
|
||||
Mix.Project.config()[:version]
|
||||
}"}
|
||||
]
|
||||
setup do
|
||||
# Config.instance_user_agent/0 makes database calls so because of ownership connection
|
||||
# we need to define it like this instead of a constant
|
||||
# See https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html
|
||||
{:ok,
|
||||
httpoison_headers: [
|
||||
{"User-Agent", Config.instance_user_agent()}
|
||||
]}
|
||||
end
|
||||
|
||||
describe "search address" do
|
||||
test "produces a valid search address with options" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
{:ok, %HTTPoison.Response{status_code: 200, body: "{\"features\": []"}}
|
||||
@@ -30,7 +33,7 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"https://photon.komoot.de/api/?q=10%20Rue%20Jangot&lang=fr&limit=5",
|
||||
@httpoison_headers
|
||||
httpoison_headers
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user