Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -9,6 +9,11 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Addok
|
||||
|
||||
@http_options [
|
||||
follow_redirect: true,
|
||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||
]
|
||||
|
||||
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
|
||||
@@ -24,17 +29,21 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
|
||||
describe "search address" do
|
||||
test "produces a valid search address", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
with_mock HTTPoison, get: fn _url, _headers, _options -> "{}" 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,
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
with_mock HTTPoison, get: fn _url, _headers, _options -> "{}" end do
|
||||
Addok.search("10 Rue Jangot",
|
||||
endpoint: @fake_endpoint,
|
||||
limit: 5,
|
||||
@@ -44,7 +53,8 @@ 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,
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -8,6 +8,11 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
||||
alias Mobilizon.Addresses.Address
|
||||
alias Mobilizon.Service.Geospatial.GoogleMaps
|
||||
|
||||
@http_options [
|
||||
follow_redirect: true,
|
||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||
]
|
||||
|
||||
describe "search address" do
|
||||
test "without API Key triggers an error" do
|
||||
assert_raise ArgumentError, "API Key required to use Google Maps", fn ->
|
||||
@@ -17,7 +22,7 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
||||
|
||||
test "produces a valid search address with options" do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url ->
|
||||
get: fn _url, _headers, _options ->
|
||||
{:ok,
|
||||
%HTTPoison.Response{status_code: 200, body: "{\"status\": \"OK\", \"results\": []}"}}
|
||||
end do
|
||||
@@ -29,7 +34,9 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
||||
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"https://maps.googleapis.com/maps/api/geocode/json?limit=5&key=toto&language=fr&address=10%20Rue%20Jangot"
|
||||
"https://maps.googleapis.com/maps/api/geocode/json?limit=5&key=toto&language=fr&address=10%20Rue%20Jangot",
|
||||
[],
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -9,6 +9,11 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.MapQuest
|
||||
|
||||
@http_options [
|
||||
follow_redirect: true,
|
||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||
]
|
||||
|
||||
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
|
||||
@@ -28,7 +33,7 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
||||
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
get: fn _url, _headers, _options ->
|
||||
{:ok,
|
||||
%HTTPoison.Response{
|
||||
status_code: 200,
|
||||
@@ -44,7 +49,8 @@ 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,
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -7,6 +7,11 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Nominatim
|
||||
|
||||
@http_options [
|
||||
follow_redirect: true,
|
||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||
]
|
||||
|
||||
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
|
||||
@@ -20,7 +25,7 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
||||
describe "search address" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
get: fn _url, _headers, _options ->
|
||||
{:ok, %HTTPoison.Response{status_code: 200, body: "[]"}}
|
||||
end do
|
||||
Nominatim.search("10 Rue Jangot",
|
||||
@@ -31,7 +36,8 @@ 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,
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -9,6 +9,11 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Photon
|
||||
|
||||
@http_options [
|
||||
follow_redirect: true,
|
||||
ssl: [{:versions, [:"tlsv1.2"]}]
|
||||
]
|
||||
|
||||
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
|
||||
@@ -22,7 +27,7 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
||||
describe "search address" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison,
|
||||
get: fn _url, _headers ->
|
||||
get: fn _url, _headers, _options ->
|
||||
{:ok, %HTTPoison.Response{status_code: 200, body: "{\"features\": []"}}
|
||||
end do
|
||||
Photon.search("10 Rue Jangot",
|
||||
@@ -33,7 +38,8 @@ 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,
|
||||
@http_options
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user