Remove credo and use mix format, and lint everything
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -7,9 +7,36 @@ defmodule Eventos.ActorsTest do
|
||||
describe "actors" do
|
||||
alias Eventos.Actors.Actor
|
||||
|
||||
@valid_attrs %{summary: "some description", name: "some name", domain: "some domain", keys: "some keypair", suspended: true, uri: "some uri", url: "some url", preferred_username: "some username"}
|
||||
@update_attrs %{summary: "some updated description", name: "some updated name", domain: "some updated domain", keys: "some updated keys", suspended: false, uri: "some updated uri", url: "some updated url", preferred_username: "some updated username"}
|
||||
@invalid_attrs %{summary: nil, name: nil, domain: nil, keys: nil, suspended: nil, uri: nil, url: nil, preferred_username: nil}
|
||||
@valid_attrs %{
|
||||
summary: "some description",
|
||||
name: "some name",
|
||||
domain: "some domain",
|
||||
keys: "some keypair",
|
||||
suspended: true,
|
||||
uri: "some uri",
|
||||
url: "some url",
|
||||
preferred_username: "some username"
|
||||
}
|
||||
@update_attrs %{
|
||||
summary: "some updated description",
|
||||
name: "some updated name",
|
||||
domain: "some updated domain",
|
||||
keys: "some updated keys",
|
||||
suspended: false,
|
||||
uri: "some updated uri",
|
||||
url: "some updated url",
|
||||
preferred_username: "some updated username"
|
||||
}
|
||||
@invalid_attrs %{
|
||||
summary: nil,
|
||||
name: nil,
|
||||
domain: nil,
|
||||
keys: nil,
|
||||
suspended: nil,
|
||||
uri: nil,
|
||||
url: nil,
|
||||
preferred_username: nil
|
||||
}
|
||||
|
||||
def actor_fixture(attrs \\ %{}) do
|
||||
{:ok, actor} =
|
||||
@@ -77,7 +104,16 @@ defmodule Eventos.ActorsTest do
|
||||
describe "users" do
|
||||
alias Eventos.Actors.{User, Actor}
|
||||
|
||||
@actor_valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", keys: "some keys", suspended: true, uri: "some uri", url: "some url", preferred_username: "some username"}
|
||||
@actor_valid_attrs %{
|
||||
description: "some description",
|
||||
display_name: "some display_name",
|
||||
domain: "some domain",
|
||||
keys: "some keys",
|
||||
suspended: true,
|
||||
uri: "some uri",
|
||||
url: "some url",
|
||||
preferred_username: "some username"
|
||||
}
|
||||
@valid_attrs %{email: "foo@bar.tld", password: "some password", role: 42}
|
||||
@update_attrs %{email: "foo@fighters.tld", password: "some updated password", role: 43}
|
||||
@invalid_attrs %{email: nil, password_hash: nil, role: nil}
|
||||
@@ -138,12 +174,21 @@ defmodule Eventos.ActorsTest do
|
||||
end
|
||||
|
||||
describe "groups" do
|
||||
|
||||
alias Eventos.Actors
|
||||
alias Eventos.Actors.Actor
|
||||
|
||||
@valid_attrs %{summary: "some description", suspended: true, preferred_username: "some-title", name: "Some Title"}
|
||||
@update_attrs %{summary: "some updated description", suspended: false, preferred_username: "some-updated-title", name: "Some Updated Title"}
|
||||
@valid_attrs %{
|
||||
summary: "some description",
|
||||
suspended: true,
|
||||
preferred_username: "some-title",
|
||||
name: "Some Title"
|
||||
}
|
||||
@update_attrs %{
|
||||
summary: "some updated description",
|
||||
suspended: false,
|
||||
preferred_username: "some-updated-title",
|
||||
name: "Some Updated Title"
|
||||
}
|
||||
@invalid_attrs %{summary: nil, suspended: nil, preferred_username: nil, name: nil}
|
||||
|
||||
test "create_group/1 with valid data creates a group" do
|
||||
@@ -184,9 +229,11 @@ defmodule Eventos.ActorsTest do
|
||||
end
|
||||
|
||||
test "create_bot/1 with valid data creates a bot" do
|
||||
attrs = @valid_attrs
|
||||
|> Map.merge(%{actor_id: insert(:actor).id})
|
||||
|> Map.merge(%{user_id: insert(:user).id})
|
||||
attrs =
|
||||
@valid_attrs
|
||||
|> Map.merge(%{actor_id: insert(:actor).id})
|
||||
|> Map.merge(%{user_id: insert(:user).id})
|
||||
|
||||
assert {:ok, %Bot{} = bot} = Actors.create_bot(attrs)
|
||||
assert bot.source == "some source"
|
||||
assert bot.type == "some type"
|
||||
|
||||
@@ -6,9 +6,36 @@ defmodule Eventos.AddressesTest do
|
||||
describe "addresses" do
|
||||
alias Eventos.Addresses.Address
|
||||
|
||||
@valid_attrs %{addressCountry: "some addressCountry", addressLocality: "some addressLocality", addressRegion: "some addressRegion", description: "some description", floor: "some floor", postalCode: "some postalCode", streetAddress: "some streetAddress", geom: %Geo.Point{coordinates: {10, -10}, srid: 4326}}
|
||||
@update_attrs %{addressCountry: "some updated addressCountry", addressLocality: "some updated addressLocality", addressRegion: "some updated addressRegion", description: "some updated description", floor: "some updated floor", postalCode: "some updated postalCode", streetAddress: "some updated streetAddress", geom: %Geo.Point{coordinates: {20, -20}, srid: 4326}}
|
||||
@invalid_attrs %{addressCountry: nil, addressLocality: nil, addressRegion: nil, description: nil, floor: nil, postalCode: nil, streetAddress: nil, geom: nil}
|
||||
@valid_attrs %{
|
||||
addressCountry: "some addressCountry",
|
||||
addressLocality: "some addressLocality",
|
||||
addressRegion: "some addressRegion",
|
||||
description: "some description",
|
||||
floor: "some floor",
|
||||
postalCode: "some postalCode",
|
||||
streetAddress: "some streetAddress",
|
||||
geom: %Geo.Point{coordinates: {10, -10}, srid: 4326}
|
||||
}
|
||||
@update_attrs %{
|
||||
addressCountry: "some updated addressCountry",
|
||||
addressLocality: "some updated addressLocality",
|
||||
addressRegion: "some updated addressRegion",
|
||||
description: "some updated description",
|
||||
floor: "some updated floor",
|
||||
postalCode: "some updated postalCode",
|
||||
streetAddress: "some updated streetAddress",
|
||||
geom: %Geo.Point{coordinates: {20, -20}, srid: 4326}
|
||||
}
|
||||
@invalid_attrs %{
|
||||
addressCountry: nil,
|
||||
addressLocality: nil,
|
||||
addressRegion: nil,
|
||||
description: nil,
|
||||
floor: nil,
|
||||
postalCode: nil,
|
||||
streetAddress: nil,
|
||||
geom: nil
|
||||
}
|
||||
|
||||
def address_fixture(attrs \\ %{}) do
|
||||
{:ok, address} =
|
||||
|
||||
@@ -6,7 +6,12 @@ defmodule Eventos.EventsTest do
|
||||
alias Eventos.Events
|
||||
alias Eventos.Actors
|
||||
|
||||
@event_valid_attrs %{begins_on: "2010-04-17 14:00:00.000000Z", description: "some description", ends_on: "2010-04-17 14:00:00.000000Z", title: "some title"}
|
||||
@event_valid_attrs %{
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
title: "some title"
|
||||
}
|
||||
|
||||
def actor_fixture do
|
||||
insert(:actor)
|
||||
@@ -27,8 +32,18 @@ defmodule Eventos.EventsTest do
|
||||
describe "events" do
|
||||
alias Eventos.Events.Event
|
||||
|
||||
@valid_attrs %{begins_on: "2010-04-17 14:00:00.000000Z", description: "some description", ends_on: "2010-04-17 14:00:00.000000Z", title: "some title"}
|
||||
@update_attrs %{begins_on: "2011-05-18 15:01:01.000000Z", description: "some updated description", ends_on: "2011-05-18 15:01:01.000000Z", title: "some updated title"}
|
||||
@valid_attrs %{
|
||||
begins_on: "2010-04-17 14:00:00.000000Z",
|
||||
description: "some description",
|
||||
ends_on: "2010-04-17 14:00:00.000000Z",
|
||||
title: "some title"
|
||||
}
|
||||
@update_attrs %{
|
||||
begins_on: "2011-05-18 15:01:01.000000Z",
|
||||
description: "some updated description",
|
||||
ends_on: "2011-05-18 15:01:01.000000Z",
|
||||
title: "some updated title"
|
||||
}
|
||||
@invalid_attrs %{begins_on: nil, description: nil, ends_on: nil, title: nil}
|
||||
|
||||
test "list_events/0 returns all events" do
|
||||
@@ -45,11 +60,14 @@ defmodule Eventos.EventsTest do
|
||||
actor = actor_fixture()
|
||||
category = category_fixture()
|
||||
address = address_fixture()
|
||||
valid_attrs = @event_valid_attrs
|
||||
|
||||
valid_attrs =
|
||||
@event_valid_attrs
|
||||
|> Map.put(:organizer_actor, actor)
|
||||
|> Map.put(:organizer_actor_id, actor.id)
|
||||
|> Map.put(:category_id, category.id)
|
||||
|> Map.put(:address_id, address.id)
|
||||
|
||||
assert {:ok, %Event{} = event} = Events.create_event(valid_attrs)
|
||||
assert event.begins_on == DateTime.from_naive!(~N[2010-04-17 14:00:00.000000Z], "Etc/UTC")
|
||||
assert event.description == "some description"
|
||||
@@ -93,7 +111,11 @@ defmodule Eventos.EventsTest do
|
||||
alias Eventos.Events.Category
|
||||
|
||||
@valid_attrs %{description: "some description", picture: "some picture", title: "some title"}
|
||||
@update_attrs %{description: "some updated description", picture: "some updated picture", title: "some updated title"}
|
||||
@update_attrs %{
|
||||
description: "some updated description",
|
||||
picture: "some updated picture",
|
||||
title: "some updated title"
|
||||
}
|
||||
@invalid_attrs %{description: nil, picture: nil, title: nil}
|
||||
|
||||
test "list_categories/0 returns all categories" do
|
||||
@@ -216,6 +238,7 @@ defmodule Eventos.EventsTest do
|
||||
actor = actor_fixture()
|
||||
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
||||
valid_attrs = Map.put(valid_attrs, :actor_id, actor.id)
|
||||
|
||||
{:ok, participant} =
|
||||
attrs
|
||||
|> Enum.into(valid_attrs)
|
||||
@@ -229,10 +252,10 @@ defmodule Eventos.EventsTest do
|
||||
assert Events.list_participants() == [participant]
|
||||
end
|
||||
|
||||
# test "get_participant!/1 returns the participant with given id" do
|
||||
# participant = participant_fixture()
|
||||
# assert Events.get_participant!(participant.id) == participant
|
||||
# end
|
||||
# test "get_participant!/1 returns the participant with given id" do
|
||||
# participant = participant_fixture()
|
||||
# assert Events.get_participant!(participant.id) == participant
|
||||
# end
|
||||
|
||||
test "create_participant/1 with valid data creates a participant" do
|
||||
actor = actor_fixture()
|
||||
@@ -273,13 +296,41 @@ defmodule Eventos.EventsTest do
|
||||
describe "sessions" do
|
||||
alias Eventos.Events.Session
|
||||
|
||||
@valid_attrs %{audios_urls: "some audios_urls", language: "some language", long_abstract: "some long_abstract", short_abstract: "some short_abstract", slides_url: "some slides_url", subtitle: "some subtitle", title: "some title", videos_urls: "some videos_urls"}
|
||||
@update_attrs %{audios_urls: "some updated audios_urls", language: "some updated language", long_abstract: "some updated long_abstract", short_abstract: "some updated short_abstract", slides_url: "some updated slides_url", subtitle: "some updated subtitle", title: "some updated title", videos_urls: "some updated videos_urls"}
|
||||
@invalid_attrs %{audios_urls: nil, language: nil, long_abstract: nil, short_abstract: nil, slides_url: nil, subtitle: nil, title: nil, videos_urls: nil}
|
||||
@valid_attrs %{
|
||||
audios_urls: "some audios_urls",
|
||||
language: "some language",
|
||||
long_abstract: "some long_abstract",
|
||||
short_abstract: "some short_abstract",
|
||||
slides_url: "some slides_url",
|
||||
subtitle: "some subtitle",
|
||||
title: "some title",
|
||||
videos_urls: "some videos_urls"
|
||||
}
|
||||
@update_attrs %{
|
||||
audios_urls: "some updated audios_urls",
|
||||
language: "some updated language",
|
||||
long_abstract: "some updated long_abstract",
|
||||
short_abstract: "some updated short_abstract",
|
||||
slides_url: "some updated slides_url",
|
||||
subtitle: "some updated subtitle",
|
||||
title: "some updated title",
|
||||
videos_urls: "some updated videos_urls"
|
||||
}
|
||||
@invalid_attrs %{
|
||||
audios_urls: nil,
|
||||
language: nil,
|
||||
long_abstract: nil,
|
||||
short_abstract: nil,
|
||||
slides_url: nil,
|
||||
subtitle: nil,
|
||||
title: nil,
|
||||
videos_urls: nil
|
||||
}
|
||||
|
||||
def session_fixture(attrs \\ %{}) do
|
||||
event = event_fixture()
|
||||
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
||||
|
||||
{:ok, session} =
|
||||
attrs
|
||||
|> Enum.into(valid_attrs)
|
||||
@@ -352,12 +403,17 @@ defmodule Eventos.EventsTest do
|
||||
alias Eventos.Events.Track
|
||||
|
||||
@valid_attrs %{color: "some color", description: "some description", name: "some name"}
|
||||
@update_attrs %{color: "some updated color", description: "some updated description", name: "some updated name"}
|
||||
@update_attrs %{
|
||||
color: "some updated color",
|
||||
description: "some updated description",
|
||||
name: "some updated name"
|
||||
}
|
||||
@invalid_attrs %{color: nil, description: nil, name: nil}
|
||||
|
||||
def track_fixture(attrs \\ %{}) do
|
||||
event = event_fixture()
|
||||
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
||||
|
||||
{:ok, track} =
|
||||
attrs
|
||||
|> Enum.into(valid_attrs)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
defmodule Eventos.Service.Activitypub.ActivitypubTest do
|
||||
|
||||
use Eventos.DataCase
|
||||
|
||||
import Eventos.Factory
|
||||
@@ -11,7 +10,8 @@ defmodule Eventos.Service.Activitypub.ActivitypubTest do
|
||||
|
||||
describe "fetching actor from it's url" do
|
||||
test "returns an actor" do
|
||||
assert {:ok, %Actor{preferred_username: "tcit", domain: "framapiaf.org"} = actor} = ActivityPub.make_actor_from_nickname("tcit@framapiaf.org")
|
||||
assert {:ok, %Actor{preferred_username: "tcit", domain: "framapiaf.org"} = actor} =
|
||||
ActivityPub.make_actor_from_nickname("tcit@framapiaf.org")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ defmodule Eventos.Service.WebFingerTest do
|
||||
|
||||
{:ok, result} =
|
||||
WebFinger.webfinger("#{actor.preferred_username}@#{EventosWeb.Endpoint.host()}", "JSON")
|
||||
|
||||
assert is_map(result)
|
||||
end
|
||||
|
||||
@@ -29,23 +30,29 @@ defmodule Eventos.Service.WebFingerTest do
|
||||
end
|
||||
|
||||
describe "fingering" do
|
||||
|
||||
test "a mastodon actor" do
|
||||
actor = "tcit@social.tcit.fr"
|
||||
|
||||
assert {:ok, %{"subject" => "acct:" <> actor, "url" => "https://social.tcit.fr/users/tcit"}} = WebFinger.finger(actor)
|
||||
assert {:ok, %{"subject" => "acct:" <> actor, "url" => "https://social.tcit.fr/users/tcit"}} =
|
||||
WebFinger.finger(actor)
|
||||
end
|
||||
|
||||
test "a pleroma actor" do
|
||||
actor = "@lain@pleroma.soykaf.com"
|
||||
|
||||
assert {:ok, %{"subject" => "acct:" <> actor, "url" => "https://pleroma.soykaf.com/users/lain"}} = WebFinger.finger(actor)
|
||||
assert {:ok,
|
||||
%{"subject" => "acct:" <> actor, "url" => "https://pleroma.soykaf.com/users/lain"}} =
|
||||
WebFinger.finger(actor)
|
||||
end
|
||||
|
||||
test "a peertube actor" do
|
||||
actor = "framasoft@framatube.org"
|
||||
|
||||
assert {:ok, %{"subject" => "acct:" <> actor, "url" => "https://framatube.org/accounts/framasoft"}} = WebFinger.finger(actor)
|
||||
assert {:ok,
|
||||
%{
|
||||
"subject" => "acct:" <> actor,
|
||||
"url" => "https://framatube.org/accounts/framasoft"
|
||||
}} = WebFinger.finger(actor)
|
||||
end
|
||||
|
||||
test "a friendica actor" do
|
||||
|
||||
Reference in New Issue
Block a user