logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

import_test.exs (1943B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.User.ImportTest do
  5. alias Pleroma.Repo
  6. alias Pleroma.Tests.ObanHelpers
  7. alias Pleroma.User
  8. use Pleroma.DataCase
  9. use Oban.Testing, repo: Pleroma.Repo
  10. import Pleroma.Factory
  11. setup_all do
  12. Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
  13. :ok
  14. end
  15. describe "follow_import" do
  16. test "it imports user followings from list" do
  17. [user1, user2, user3] = insert_list(3, :user)
  18. identifiers = [
  19. user2.ap_id,
  20. user3.nickname
  21. ]
  22. {:ok, job} = User.Import.follow_import(user1, identifiers)
  23. assert {:ok, result} = ObanHelpers.perform(job)
  24. assert is_list(result)
  25. assert result == [user2, user3]
  26. assert User.following?(user1, user2)
  27. assert User.following?(user1, user3)
  28. end
  29. end
  30. describe "blocks_import" do
  31. test "it imports user blocks from list" do
  32. [user1, user2, user3] = insert_list(3, :user)
  33. identifiers = [
  34. user2.ap_id,
  35. user3.nickname
  36. ]
  37. {:ok, job} = User.Import.blocks_import(user1, identifiers)
  38. assert {:ok, result} = ObanHelpers.perform(job)
  39. assert is_list(result)
  40. assert result == [user2, user3]
  41. assert User.blocks?(user1, user2)
  42. assert User.blocks?(user1, user3)
  43. end
  44. end
  45. describe "mutes_import" do
  46. test "it imports user mutes from list" do
  47. [user1, user2, user3] = insert_list(3, :user)
  48. identifiers = [
  49. user2.ap_id,
  50. user3.nickname
  51. ]
  52. {:ok, job} = User.Import.mutes_import(user1, identifiers)
  53. assert {:ok, result} = ObanHelpers.perform(job)
  54. assert is_list(result)
  55. assert result == [user2, user3]
  56. assert User.mutes?(user1, user2)
  57. assert User.mutes?(user1, user3)
  58. end
  59. end
  60. end