Fix tests
This commit is contained in:
parent
b62be2564c
commit
5869a43fe7
|
@ -75,6 +75,23 @@ def render_json(view, template, assigns) do
|
|||
|> Poison.decode!()
|
||||
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
|
||||
quote do
|
||||
initial_setting = Pleroma.Config.get(config_path)
|
||||
|
|
|
@ -1654,9 +1654,10 @@ test "returns reports grouped by status", %{
|
|||
NaiveDateTime.from_iso8601!(act.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 hd(first_group["actors"])["id"] == reporter.id
|
||||
|
@ -1669,11 +1670,8 @@ test "returns reports grouped by status", %{
|
|||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert second_group["status"] == %{
|
||||
"id" => second_status.data["id"],
|
||||
"content" => second_status.object.data["content"],
|
||||
"published" => second_status.object.data["published"]
|
||||
}
|
||||
assert second_group["status"] ==
|
||||
stringify_keys(StatusView.render("show.json", %{activity: second_status}))
|
||||
|
||||
assert second_group["account"]["id"] == target_user.id
|
||||
|
||||
|
@ -1688,11 +1686,8 @@ test "returns reports grouped by status", %{
|
|||
NaiveDateTime.from_iso8601!(act.data["published"])
|
||||
end).data["published"]
|
||||
|
||||
assert third_group["status"] == %{
|
||||
"id" => third_status.data["id"],
|
||||
"content" => third_status.object.data["content"],
|
||||
"published" => third_status.object.data["published"]
|
||||
}
|
||||
assert third_group["status"] ==
|
||||
stringify_keys(StatusView.render("show.json", %{activity: third_status}))
|
||||
|
||||
assert third_group["account"]["id"] == target_user.id
|
||||
|
||||
|
|
Loading…
Reference in New Issue