diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2019-12-08 19:52:46 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2019-12-08 19:52:46 +0300 |
commit | 5876a9cb79e53f932d63e457610852031669a222 (patch) | |
tree | 6ff7335e9ddd5cfbce1e33ca075265c6f31b8b61 /test/support | |
parent | 3c3bba0b7c65187b3270ef3402442cf870a55198 (diff) | |
parent | af5fef1f228a1781d7d9cad490d3b3a783389f5e (diff) | |
download | pleroma-5876a9cb79e53f932d63e457610852031669a222.tar.gz |
Merge branch 'develop' into issue/1383
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/channel_case.ex | 1 | ||||
-rw-r--r-- | test/support/factory.ex | 12 | ||||
-rw-r--r-- | test/support/helpers.ex | 17 |
3 files changed, 30 insertions, 0 deletions
diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex index 466d8986f..4a4585844 100644 --- a/test/support/channel_case.ex +++ b/test/support/channel_case.ex @@ -23,6 +23,7 @@ defmodule Pleroma.Web.ChannelCase do quote do # Import conveniences for testing with channels use Phoenix.ChannelTest + use Pleroma.Tests.Helpers # The default endpoint for testing @endpoint Pleroma.Web.Endpoint diff --git a/test/support/factory.ex b/test/support/factory.ex index bb8a64e72..35ba523a1 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -42,6 +42,18 @@ defmodule Pleroma.Factory do } end + def user_relationship_factory(attrs \\ %{}) do + source = attrs[:source] || insert(:user) + target = attrs[:target] || insert(:user) + relationship_type = attrs[:relationship_type] || :block + + %Pleroma.UserRelationship{ + source_id: source.id, + target_id: target.id, + relationship_type: relationship_type + } + end + def note_factory(attrs \\ %{}) do text = sequence(:text, &"This is :moominmamma: note #{&1}") diff --git a/test/support/helpers.ex b/test/support/helpers.ex index ec556a916..7bda09162 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -81,6 +81,23 @@ defmodule Pleroma.Tests.Helpers 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) |