1 defmodule Pleroma.Factory do
2 use ExMachina.Ecto, repo: Pleroma.Repo
6 name: sequence(:name, &"Test ใในใ User #{&1}"),
7 email: sequence(:email, &"user#{&1}@example.com"),
8 nickname: sequence(:nickname, &"nick#{&1}"),
9 password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
10 bio: sequence(:bio, &"Tester Number #{&1}")
12 %{ user | ap_id: Pleroma.User.ap_id(user), follower_address: Pleroma.User.ap_followers(user) }
16 text = sequence(:text, &"This is :moominmamma: note #{&1}")
22 "id" => Pleroma.Web.ActivityPub.Utils.generate_object_id,
23 "actor" => user.ap_id,
24 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
25 "published" => DateTime.utc_now() |> DateTime.to_iso8601,
31 "2hu" => "corndog.png"
40 def note_activity_factory do
43 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
45 "actor" => note.data["actor"],
46 "to" => note.data["to"],
47 "object" => note.data,
48 "published" => DateTime.utc_now() |> DateTime.to_iso8601,
49 "context" => note.data["context"]
57 def like_activity_factory do
58 note_activity = insert(:note_activity)
62 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
63 "actor" => user.ap_id,
65 "object" => note_activity.data["object"]["id"],
66 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
74 def follow_activity_factory do
75 follower = insert(:user)
76 followed = insert(:user)
79 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
80 "actor" => follower.ap_id,
82 "object" => followed.ap_id,
83 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
91 def websub_subscription_factory do
92 %Pleroma.Web.Websub.WebsubServerSubscription{
93 topic: "http://example.org",
94 callback: "http://example/org/callback",
95 secret: "here's a secret",
96 valid_until: NaiveDateTime.add(NaiveDateTime.utc_now, 100),
101 def websub_client_subscription_factory do
102 %Pleroma.Web.Websub.WebsubClientSubscription{
103 topic: "http://example.org",
104 secret: "here's a secret",