MastoAPI AccountView AccountController: Add more block/mute expiry tests
This commit is contained in:
parent
f4a8c426df
commit
521fc70e48
2 changed files with 97 additions and 12 deletions
|
|
@ -1901,7 +1901,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|
|
||||||
{:ok, _user_relationships} = User.mute(user, other_user1)
|
{:ok, _user_relationships} = User.mute(user, other_user1)
|
||||||
{:ok, _user_relationships} = User.mute(user, other_user2)
|
{:ok, _user_relationships} = User.mute(user, other_user2)
|
||||||
{:ok, _user_relationships} = User.mute(user, other_user3)
|
{:ok, _user_relationships} = User.mute(user, other_user3, %{duration: 24 * 60 * 60})
|
||||||
|
|
||||||
|
date =
|
||||||
|
DateTime.utc_now()
|
||||||
|
|> DateTime.add(24 * 60 * 60)
|
||||||
|
|> DateTime.truncate(:second)
|
||||||
|
|> DateTime.to_iso8601()
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
|
@ -1937,6 +1943,17 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id3}] = result
|
assert [%{"id" => ^id3}] = result
|
||||||
|
|
||||||
|
result =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/mutes")
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert [
|
||||||
|
%{"id" => ^id3, "mute_expires_at" => ^date},
|
||||||
|
%{"id" => ^id2, "mute_expires_at" => nil},
|
||||||
|
%{"id" => ^id1, "mute_expires_at" => nil}
|
||||||
|
] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
test "list of mutes with with_relationships parameter" do
|
test "list of mutes with with_relationships parameter" do
|
||||||
|
|
@ -1951,20 +1968,44 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|
|
||||||
{:ok, _} = User.mute(user, other_user1)
|
{:ok, _} = User.mute(user, other_user1)
|
||||||
{:ok, _} = User.mute(user, other_user2)
|
{:ok, _} = User.mute(user, other_user2)
|
||||||
{:ok, _} = User.mute(user, other_user3)
|
{:ok, _} = User.mute(user, other_user3, %{duration: 24 * 60 * 60})
|
||||||
|
|
||||||
|
date =
|
||||||
|
DateTime.utc_now()
|
||||||
|
|> DateTime.add(24 * 60 * 60)
|
||||||
|
|> DateTime.truncate(:second)
|
||||||
|
|> DateTime.to_iso8601()
|
||||||
|
|
||||||
assert [
|
assert [
|
||||||
%{
|
%{
|
||||||
"id" => ^id3,
|
"id" => ^id3,
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"muting" => true,
|
||||||
|
"mute_expires_at" => ^date,
|
||||||
|
"followed_by" => true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"id" => ^id2,
|
"id" => ^id2,
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"muting" => true,
|
||||||
|
"mute_expires_at" => nil,
|
||||||
|
"followed_by" => true
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"id" => ^id1,
|
"id" => ^id1,
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"muting" => true,
|
||||||
|
"mute_expires_at" => nil,
|
||||||
|
"followed_by" => true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
] =
|
] =
|
||||||
conn
|
conn
|
||||||
|
|
@ -1980,7 +2021,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|
|
||||||
{:ok, _user_relationship} = User.block(user, other_user1)
|
{:ok, _user_relationship} = User.block(user, other_user1)
|
||||||
{:ok, _user_relationship} = User.block(user, other_user3)
|
{:ok, _user_relationship} = User.block(user, other_user3)
|
||||||
{:ok, _user_relationship} = User.block(user, other_user2)
|
{:ok, _user_relationship} = User.block(user, other_user2, %{duration: 24 * 60 * 60})
|
||||||
|
|
||||||
|
date =
|
||||||
|
DateTime.utc_now()
|
||||||
|
|> DateTime.add(24 * 60 * 60)
|
||||||
|
|> DateTime.truncate(:second)
|
||||||
|
|> DateTime.to_iso8601()
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
|
@ -2045,6 +2092,18 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id1}] = result
|
assert [%{"id" => ^id1}] = result
|
||||||
|
|
||||||
|
result =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> get("api/v1/blocks")
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert [
|
||||||
|
%{"id" => ^id3, "block_expires_at" => nil},
|
||||||
|
%{"id" => ^id2, "block_expires_at" => ^date},
|
||||||
|
%{"id" => ^id1, "block_expires_at" => nil}
|
||||||
|
] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
test "list of blocks with with_relationships parameter" do
|
test "list of blocks with with_relationships parameter" do
|
||||||
|
|
@ -2059,20 +2118,44 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|
|
||||||
{:ok, _} = User.block(user, other_user1)
|
{:ok, _} = User.block(user, other_user1)
|
||||||
{:ok, _} = User.block(user, other_user2)
|
{:ok, _} = User.block(user, other_user2)
|
||||||
{:ok, _} = User.block(user, other_user3)
|
{:ok, _} = User.block(user, other_user3, %{duration: 24 * 60 * 60})
|
||||||
|
|
||||||
|
date =
|
||||||
|
DateTime.utc_now()
|
||||||
|
|> DateTime.add(24 * 60 * 60)
|
||||||
|
|> DateTime.truncate(:second)
|
||||||
|
|> DateTime.to_iso8601()
|
||||||
|
|
||||||
assert [
|
assert [
|
||||||
%{
|
%{
|
||||||
"id" => ^id3,
|
"id" => ^id3,
|
||||||
"pleroma" => %{"relationship" => %{"blocking" => true, "followed_by" => false}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"blocking" => true,
|
||||||
|
"block_expires_at" => ^date,
|
||||||
|
"followed_by" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"id" => ^id2,
|
"id" => ^id2,
|
||||||
"pleroma" => %{"relationship" => %{"blocking" => true, "followed_by" => false}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"blocking" => true,
|
||||||
|
"block_expires_at" => nil,
|
||||||
|
"followed_by" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"id" => ^id1,
|
"id" => ^id1,
|
||||||
"pleroma" => %{"relationship" => %{"blocking" => true, "followed_by" => false}}
|
"pleroma" => %{
|
||||||
|
"relationship" => %{
|
||||||
|
"blocking" => true,
|
||||||
|
"block_expires_at" => nil,
|
||||||
|
"followed_by" => false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
] =
|
] =
|
||||||
conn
|
conn
|
||||||
|
|
|
||||||
|
|
@ -909,7 +909,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||||
relationship: %{
|
relationship: %{
|
||||||
mute_expires_at: mute_expires_at
|
mute_expires_at: mute_expires_at
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
mute_expires_at: mute_expires_at
|
||||||
} = AccountView.render("show.json", %{user: other_user, for: user, embed_relationships: true})
|
} = AccountView.render("show.json", %{user: other_user, for: user, embed_relationships: true})
|
||||||
|
|
||||||
assert DateTime.diff(
|
assert DateTime.diff(
|
||||||
|
|
@ -930,7 +931,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||||
relationship: %{
|
relationship: %{
|
||||||
block_expires_at: block_expires_at
|
block_expires_at: block_expires_at
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
block_expires_at: block_expires_at
|
||||||
} = AccountView.render("show.json", %{user: other_user, for: user, embed_relationships: true})
|
} = AccountView.render("show.json", %{user: other_user, for: user, embed_relationships: true})
|
||||||
|
|
||||||
assert DateTime.diff(
|
assert DateTime.diff(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue