diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-04-28 14:13:53 +0400 | 
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-04-28 14:13:53 +0400 | 
| commit | 764b4f95a8e9e751d5a6136fc2be44d61a082443 (patch) | |
| tree | fbeea45e76ca9053a19dc41e6b02158c222821bf /test/web/mastodon_api | |
| parent | c56c0a3d23929f166f4d95e5c6e96bbf0df8a35e (diff) | |
| parent | 9994768312ede572c4ddd6beda7027b0a2baddce (diff) | |
| download | pleroma-764b4f95a8e9e751d5a6136fc2be44d61a082443.tar.gz pleroma-764b4f95a8e9e751d5a6136fc2be44d61a082443.zip | |
Merge branch 'develop' into global-status-expiration
Diffstat (limited to 'test/web/mastodon_api')
3 files changed, 10 insertions, 39 deletions
| diff --git a/test/web/mastodon_api/controllers/app_controller_test.exs b/test/web/mastodon_api/controllers/app_controller_test.exs index e7b11d14e..a0b8b126c 100644 --- a/test/web/mastodon_api/controllers/app_controller_test.exs +++ b/test/web/mastodon_api/controllers/app_controller_test.exs @@ -27,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.AppControllerTest do        "vapid_key" => Push.vapid_config() |> Keyword.get(:public_key)      } -    assert expected == json_response(conn, 200) +    assert expected == json_response_and_validate_schema(conn, 200)    end    test "creates an oauth app", %{conn: conn} do @@ -55,6 +55,6 @@ defmodule Pleroma.Web.MastodonAPI.AppControllerTest do        "vapid_key" => Push.vapid_config() |> Keyword.get(:public_key)      } -    assert expected == json_response(conn, 200) +    assert expected == json_response_and_validate_schema(conn, 200)    end  end diff --git a/test/web/mastodon_api/controllers/custom_emoji_controller_test.exs b/test/web/mastodon_api/controllers/custom_emoji_controller_test.exs index 0b2ffa470..4222556a4 100644 --- a/test/web/mastodon_api/controllers/custom_emoji_controller_test.exs +++ b/test/web/mastodon_api/controllers/custom_emoji_controller_test.exs @@ -5,15 +5,13 @@  defmodule Pleroma.Web.MastodonAPI.CustomEmojiControllerTest do    use Pleroma.Web.ConnCase, async: true    alias Pleroma.Web.ApiSpec -  alias Pleroma.Web.ApiSpec.Schemas.CustomEmoji -  alias Pleroma.Web.ApiSpec.Schemas.CustomEmojisResponse    import OpenApiSpex.TestAssertions    test "with tags", %{conn: conn} do      assert resp =               conn               |> get("/api/v1/custom_emojis") -             |> json_response(200) +             |> json_response_and_validate_schema(200)      assert [emoji | _body] = resp      assert Map.has_key?(emoji, "shortcode") @@ -23,19 +21,6 @@ defmodule Pleroma.Web.MastodonAPI.CustomEmojiControllerTest do      assert Map.has_key?(emoji, "category")      assert Map.has_key?(emoji, "url")      assert Map.has_key?(emoji, "visible_in_picker") -    assert_schema(resp, "CustomEmojisResponse", ApiSpec.spec())      assert_schema(emoji, "CustomEmoji", ApiSpec.spec())    end - -  test "CustomEmoji example matches schema" do -    api_spec = ApiSpec.spec() -    schema = CustomEmoji.schema() -    assert_schema(schema.example, "CustomEmoji", api_spec) -  end - -  test "CustomEmojisResponse example matches schema" do -    api_spec = ApiSpec.spec() -    schema = CustomEmojisResponse.schema() -    assert_schema(schema.example, "CustomEmojisResponse", api_spec) -  end  end diff --git a/test/web/mastodon_api/controllers/domain_block_controller_test.exs b/test/web/mastodon_api/controllers/domain_block_controller_test.exs index d66190c90..01a24afcf 100644 --- a/test/web/mastodon_api/controllers/domain_block_controller_test.exs +++ b/test/web/mastodon_api/controllers/domain_block_controller_test.exs @@ -6,11 +6,8 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do    use Pleroma.Web.ConnCase    alias Pleroma.User -  alias Pleroma.Web.ApiSpec -  alias Pleroma.Web.ApiSpec.Schemas.DomainBlocksResponse    import Pleroma.Factory -  import OpenApiSpex.TestAssertions    test "blocking / unblocking a domain" do      %{user: user, conn: conn} = oauth_access(["write:blocks"]) @@ -21,7 +18,7 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do        |> put_req_header("content-type", "application/json")        |> post("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) -    assert %{} = json_response(ret_conn, 200) +    assert %{} == json_response_and_validate_schema(ret_conn, 200)      user = User.get_cached_by_ap_id(user.ap_id)      assert User.blocks?(user, other_user) @@ -30,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do        |> put_req_header("content-type", "application/json")        |> delete("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) -    assert %{} = json_response(ret_conn, 200) +    assert %{} == json_response_and_validate_schema(ret_conn, 200)      user = User.get_cached_by_ap_id(user.ap_id)      refute User.blocks?(user, other_user)    end @@ -41,21 +38,10 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do      {:ok, user} = User.block_domain(user, "bad.site")      {:ok, user} = User.block_domain(user, "even.worse.site") -    conn = -      conn -      |> assign(:user, user) -      |> get("/api/v1/domain_blocks") - -    domain_blocks = json_response(conn, 200) - -    assert "bad.site" in domain_blocks -    assert "even.worse.site" in domain_blocks -    assert_schema(domain_blocks, "DomainBlocksResponse", ApiSpec.spec()) -  end - -  test "DomainBlocksResponse example matches schema" do -    api_spec = ApiSpec.spec() -    schema = DomainBlocksResponse.schema() -    assert_schema(schema.example, "DomainBlocksResponse", api_spec) +    assert ["even.worse.site", "bad.site"] == +             conn +             |> assign(:user, user) +             |> get("/api/v1/domain_blocks") +             |> json_response_and_validate_schema(200)    end  end | 
