1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.User.ImportTest do
6 alias Pleroma.Tests.ObanHelpers
10 use Oban.Testing, repo: Pleroma.Repo
12 import Pleroma.Factory
15 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
19 describe "follow_import" do
20 test "it imports user followings from list" do
21 [user1, user2, user3] = insert_list(3, :user)
28 [{:ok, job1}, {:ok, job2}] = User.Import.follow_import(user1, identifiers)
30 assert {:ok, result} = ObanHelpers.perform(job1)
31 assert result == refresh_record(user2)
33 assert {:ok, result} = ObanHelpers.perform(job2)
34 assert result == refresh_record(user3)
36 assert User.following?(user1, user2)
37 assert User.following?(user1, user3)
41 describe "blocks_import" do
42 test "it imports user blocks from list" do
43 [user1, user2, user3] = insert_list(3, :user)
50 [{:ok, job1}, {:ok, job2}] = User.Import.blocks_import(user1, identifiers)
52 assert {:ok, result} = ObanHelpers.perform(job1)
53 assert result == user2
55 assert {:ok, result} = ObanHelpers.perform(job2)
56 assert result == user3
58 assert User.blocks?(user1, user2)
59 assert User.blocks?(user1, user3)
63 describe "mutes_import" do
64 test "it imports user mutes from list" do
65 [user1, user2, user3] = insert_list(3, :user)
72 [{:ok, job1}, {:ok, job2}] = User.Import.mutes_import(user1, identifiers)
74 assert {:ok, result} = ObanHelpers.perform(job1)
75 assert result == user2
77 assert {:ok, result} = ObanHelpers.perform(job2)
78 assert result == user3
80 assert User.mutes?(user1, user2)
81 assert User.mutes?(user1, user3)