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
7 alias Pleroma.Tests.ObanHelpers
11 use Oban.Testing, repo: Pleroma.Repo
13 import Pleroma.Factory
16 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
20 describe "follow_import" do
21 test "it imports user followings from list" do
22 [user1, user2, user3] = insert_list(3, :user)
29 {:ok, job} = User.Import.follow_import(user1, identifiers)
31 assert {:ok, result} = ObanHelpers.perform(job)
32 assert is_list(result)
33 assert result == [refresh_record(user2), refresh_record(user3)]
34 assert User.following?(user1, user2)
35 assert User.following?(user1, user3)
39 describe "blocks_import" do
40 test "it imports user blocks from list" do
41 [user1, user2, user3] = insert_list(3, :user)
48 {:ok, job} = User.Import.blocks_import(user1, identifiers)
50 assert {:ok, result} = ObanHelpers.perform(job)
51 assert is_list(result)
52 assert result == [user2, user3]
53 assert User.blocks?(user1, user2)
54 assert User.blocks?(user1, user3)
58 describe "mutes_import" do
59 test "it imports user mutes from list" do
60 [user1, user2, user3] = insert_list(3, :user)
67 {:ok, job} = User.Import.mutes_import(user1, identifiers)
69 assert {:ok, result} = ObanHelpers.perform(job)
70 assert is_list(result)
71 assert result == [user2, user3]
72 assert User.mutes?(user1, user2)
73 assert User.mutes?(user1, user3)