diff options
| author | lain <lain@soykaf.club> | 2019-04-08 14:10:51 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2019-04-08 14:10:51 +0200 | 
| commit | a9f805c87100fd2ee1d8426460b81af4a235d574 (patch) | |
| tree | 70179175f0ff84f3f4c7399f63694766aaa65b35 /test/support | |
| parent | 5d871173d189a0019fda0ee76f8a324d90a163ee (diff) | |
| parent | 4977e96fa408e8148a355b3c759af34ae3ca312d (diff) | |
| download | pleroma-a9f805c87100fd2ee1d8426460b81af4a235d574.tar.gz pleroma-a9f805c87100fd2ee1d8426460b81af4a235d574.zip  | |
Merge remote-tracking branch 'origin/develop' into features/mastoapi/2.6.0-conversations
Diffstat (limited to 'test/support')
| -rw-r--r-- | test/support/factory.ex | 36 | ||||
| -rw-r--r-- | test/support/http_request_mock.ex | 37 | 
2 files changed, 72 insertions, 1 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index 18f77f01a..ea59912cf 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -216,7 +216,7 @@ defmodule Pleroma.Factory do        redirect_uris: "https://example.com/callback",        scopes: ["read", "write", "follow", "push"],        website: "https://example.com", -      client_id: "aaabbb==", +      client_id: Ecto.UUID.generate(),        client_secret: "aaa;/&bbb"      }    end @@ -240,6 +240,16 @@ defmodule Pleroma.Factory do      }    end +  def oauth_authorization_factory do +    %Pleroma.Web.OAuth.Authorization{ +      token: :crypto.strong_rand_bytes(32) |> Base.url_encode64(padding: false), +      scopes: ["read", "write", "follow", "push"], +      valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), 60 * 10), +      user: build(:user), +      app: build(:oauth_app) +    } +  end +    def push_subscription_factory do      %Pleroma.Web.Push.Subscription{        user: build(:user), @@ -257,4 +267,28 @@ defmodule Pleroma.Factory do        user: build(:user)      }    end + +  def scheduled_activity_factory do +    %Pleroma.ScheduledActivity{ +      user: build(:user), +      scheduled_at: NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(60), :millisecond), +      params: build(:note) |> Map.from_struct() |> Map.get(:data) +    } +  end + +  def registration_factory do +    user = insert(:user) + +    %Pleroma.Registration{ +      user: user, +      provider: "twitter", +      uid: "171799000", +      info: %{ +        "name" => "John Doe", +        "email" => "john@doe.com", +        "nickname" => "johndoe", +        "description" => "My bio" +      } +    } +  end  end diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex index 78e8efc9d..d3b547d91 100644 --- a/test/support/http_request_mock.ex +++ b/test/support/http_request_mock.ex @@ -36,6 +36,43 @@ defmodule HttpRequestMock do       }}    end +  def get("https://mastodon.social/users/emelie/statuses/101849165031453009", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/httpoison_mock/status.emelie.json") +     }} +  end + +  def get("https://mastodon.social/users/emelie", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/httpoison_mock/emelie.json") +     }} +  end + +  def get( +        "https://mastodon.social/.well-known/webfinger?resource=https://mastodon.social/users/emelie", +        _, +        _, +        _ +      ) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/httpoison_mock/webfinger_emelie.json") +     }} +  end + +  def get("https://mastodon.social/users/emelie.atom", _, _, _) do +    {:ok, +     %Tesla.Env{ +       status: 200, +       body: File.read!("test/fixtures/httpoison_mock/emelie.atom") +     }} +  end +    def get(          "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",          _,  | 
