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) }
16 text = sequence(:text, &"This is 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,
37 def note_activity_factory do
40 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
42 "actor" => note.data["actor"],
43 "to" => note.data["to"],
44 "object" => note.data,
45 "published" => DateTime.utc_now() |> DateTime.to_iso8601,
46 "context" => note.data["context"]
54 def like_activity_factory do
55 note_activity = insert(:note_activity)
59 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
60 "actor" => user.ap_id,
62 "object" => note_activity.data["object"]["id"],
63 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
71 def follow_activity_factory do
72 follower = insert(:user)
73 followed = insert(:user)
76 "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
77 "actor" => follower.ap_id,
79 "object" => followed.ap_id,
80 "published_at" => DateTime.utc_now() |> DateTime.to_iso8601
88 def websub_subscription_factory do
89 %Pleroma.Web.Websub.WebsubServerSubscription{
90 topic: "http://example.org",
91 callback: "http://example/org/callback",
92 secret: "here's a secret",
93 valid_until: NaiveDateTime.add(NaiveDateTime.utc_now, 100),
98 def websub_client_subscription_factory do
99 %Pleroma.Web.Websub.WebsubClientSubscription{
100 topic: "http://example.org",
101 secret: "here's a secret",