1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicyTest do
9 alias Pleroma.Tests.ObanHelpers
10 alias Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy
18 "content" => "content",
20 %{"url" => [%{"href" => "http://example.com/image.jpg"}]}
25 setup do: clear_config([:media_proxy, :enabled], true)
27 test "it prefetches media proxy URIs" do
28 with_mock HTTP, get: fn _, _, _ -> {:ok, []} end do
29 MediaProxyWarmingPolicy.filter(@message)
31 ObanHelpers.perform_all()
32 # Performing jobs which has been just enqueued
33 ObanHelpers.perform_all()
35 assert called(HTTP.get(:_, :_, :_))
39 test "it does nothing when no attachments are present" do
42 |> Map.delete("attachment")
46 |> Map.put("object", object)
48 with_mock HTTP, get: fn _, _, _ -> {:ok, []} end do
49 MediaProxyWarmingPolicy.filter(message)
50 refute called(HTTP.get(:_, :_, :_))