logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

import_test.exs (1842B)


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