1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Uploaders.MDIITest do
7 alias Pleroma.Uploaders.MDII
10 describe "get_file/1" do
11 test "it returns path to local folder for files" do
12 assert MDII.get_file("") == {:ok, {:static_dir, "test/uploads"}}
16 describe "put_file/1" do
18 file_upload = %Pleroma.Upload{
19 name: "mdii-image.jpg",
20 content_type: "image/jpg",
21 path: "test_folder/mdii-image.jpg",
22 tempfile: Path.absname("test/fixtures/image_tmp.jpg")
25 [file_upload: file_upload]
28 test "save file", %{file_upload: file_upload} do
30 %{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
31 %Tesla.Env{status: 200, body: "mdii-image"}
34 assert MDII.put_file(file_upload) ==
35 {:ok, {:url, "https://mdii.sakura.ne.jp/mdii-image.jpg"}}
38 test "save file to local if MDII isn`t available", %{file_upload: file_upload} do
40 %{method: :post, url: "https://mdii.sakura.ne.jp/mdii-post.cgi?jpg"} ->
41 %Tesla.Env{status: 500}
44 assert MDII.put_file(file_upload) == :ok
46 assert Path.join([Pleroma.Uploaders.Local.upload_path(), file_upload.path])