2019-09-22 18:29:13 +02:00
|
|
|
defmodule Mobilizon.Service.ActivityPub.Converter.ActorTest do
|
2019-05-22 14:12:11 +02:00
|
|
|
use Mobilizon.DataCase
|
2019-09-22 16:26:23 +02:00
|
|
|
|
2019-05-22 14:12:11 +02:00
|
|
|
alias Mobilizon.Actors.Actor
|
2019-09-22 18:29:13 +02:00
|
|
|
alias Mobilizon.Service.ActivityPub.Converter.Actor, as: ActorConverter
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
describe "actor to AS" do
|
|
|
|
test "valid actor to as" do
|
|
|
|
data = ActorConverter.model_to_as(%Actor{type: :Person, preferred_username: "test_account"})
|
|
|
|
assert is_map(data)
|
|
|
|
assert data["type"] == "Person"
|
|
|
|
assert data["preferred_username"] == "test_account"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "AS to Actor" do
|
|
|
|
test "valid as data to model" do
|
2019-10-25 17:43:37 +02:00
|
|
|
{:ok, actor} =
|
2019-05-22 14:12:11 +02:00
|
|
|
ActorConverter.as_to_model_data(%{
|
|
|
|
"type" => "Person",
|
2019-09-04 18:24:31 +02:00
|
|
|
"preferredUsername" => "test_account"
|
2019-05-22 14:12:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
assert actor["type"] == :Person
|
|
|
|
assert actor["preferred_username"] == "test_account"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|