forked from AkkomaGang/akkoma
Fix tests
This commit is contained in:
parent
b62be2564c
commit
5869a43fe7
2 changed files with 24 additions and 12 deletions
|
@ -75,6 +75,23 @@ def render_json(view, template, assigns) do
|
||||||
|> Poison.decode!()
|
|> Poison.decode!()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stringify_keys(nil), do: nil
|
||||||
|
|
||||||
|
def stringify_keys(key) when key in [true, false], do: key
|
||||||
|
def stringify_keys(key) when is_atom(key), do: Atom.to_string(key)
|
||||||
|
|
||||||
|
def stringify_keys(map) when is_map(map) do
|
||||||
|
map
|
||||||
|
|> Enum.map(fn {k, v} -> {stringify_keys(k), stringify_keys(v)} end)
|
||||||
|
|> Enum.into(%{})
|
||||||
|
end
|
||||||
|
|
||||||
|
def stringify_keys([head | rest] = list) when is_list(list) do
|
||||||
|
[stringify_keys(head) | stringify_keys(rest)]
|
||||||
|
end
|
||||||
|
|
||||||
|
def stringify_keys(key), do: key
|
||||||
|
|
||||||
defmacro guards_config(config_path) do
|
defmacro guards_config(config_path) do
|
||||||
quote do
|
quote do
|
||||||
initial_setting = Pleroma.Config.get(config_path)
|
initial_setting = Pleroma.Config.get(config_path)
|
||||||
|
|
|
@ -1654,9 +1654,10 @@ test "returns reports grouped by status", %{
|
||||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||||
end).data["published"]
|
end).data["published"]
|
||||||
|
|
||||||
assert first_group["status"] == StatusView.render("show.json", %{activity: first_status})
|
assert first_group["status"] ==
|
||||||
|
stringify_keys(StatusView.render("show.json", %{activity: first_status}))
|
||||||
|
|
||||||
assert first_group["account"]["id"] == target_user.id
|
assert(first_group["account"]["id"] == target_user.id)
|
||||||
|
|
||||||
assert length(first_group["actors"]) == 1
|
assert length(first_group["actors"]) == 1
|
||||||
assert hd(first_group["actors"])["id"] == reporter.id
|
assert hd(first_group["actors"])["id"] == reporter.id
|
||||||
|
@ -1669,11 +1670,8 @@ test "returns reports grouped by status", %{
|
||||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||||
end).data["published"]
|
end).data["published"]
|
||||||
|
|
||||||
assert second_group["status"] == %{
|
assert second_group["status"] ==
|
||||||
"id" => second_status.data["id"],
|
stringify_keys(StatusView.render("show.json", %{activity: second_status}))
|
||||||
"content" => second_status.object.data["content"],
|
|
||||||
"published" => second_status.object.data["published"]
|
|
||||||
}
|
|
||||||
|
|
||||||
assert second_group["account"]["id"] == target_user.id
|
assert second_group["account"]["id"] == target_user.id
|
||||||
|
|
||||||
|
@ -1688,11 +1686,8 @@ test "returns reports grouped by status", %{
|
||||||
NaiveDateTime.from_iso8601!(act.data["published"])
|
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||||
end).data["published"]
|
end).data["published"]
|
||||||
|
|
||||||
assert third_group["status"] == %{
|
assert third_group["status"] ==
|
||||||
"id" => third_status.data["id"],
|
stringify_keys(StatusView.render("show.json", %{activity: third_status}))
|
||||||
"content" => third_status.object.data["content"],
|
|
||||||
"published" => third_status.object.data["published"]
|
|
||||||
}
|
|
||||||
|
|
||||||
assert third_group["account"]["id"] == target_user.id
|
assert third_group["account"]["id"] == target_user.id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue