1 defmodule Pleroma.Web.RichMedia.ParserTest do
2 use ExUnit.Case, async: true
8 url: "http://example.com/ogp"
10 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}
14 url: "http://example.com/twitter-card"
16 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/twitter_card.html")}
20 url: "http://example.com/oembed"
22 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/oembed.html")}
26 url: "http://example.com/oembed.json"
28 %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/oembed.json")}
30 %{method: :get, url: "http://example.com/empty"} ->
31 %Tesla.Env{status: 200, body: "hello"}
37 test "returns error when no metadata present" do
38 assert {:error, _} = Pleroma.Web.RichMedia.Parser.parse("http://example.com/empty")
42 assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp") ==
45 image: "http://ia.media-imdb.com/images/rock.jpg",
48 url: "http://www.imdb.com/title/tt0117500/"
52 test "parses twitter card" do
53 assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/twitter-card") ==
58 image: "https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg",
59 title: "Small Island Developing States Photo Submission",
60 description: "View the album on Flickr."
64 test "parses OEmbed" do
65 assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/oembed") ==
68 author_name: "bees",
69 author_url: "https://www.flickr.com/photos/bees/",
74 "<a data-flickr-embed=\"true\" href=\"https://www.flickr.com/photos/bees/2362225867/\" title=\"Bacon Lollys by bees, on Flickr\"><img src=\"https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg\" width=\"1024\" height=\"768\" alt=\"Bacon Lollys\"></a><script async src=\"https://embedr.flickr.com/assets/client-code.js\" charset=\"utf-8\"></script>",
75 license: "All Rights Reserved",
77 provider_name: "Flickr",
78 provider_url: "https://www.flickr.com/",
79 thumbnail_height: 150,
80 thumbnail_url: "https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_q.jpg",
82 title: "Bacon Lollys",
84 url: "https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg",
86 web_page: "https://www.flickr.com/photos/bees/2362225867/",
87 web_page_short_url: "https://flic.kr/p/4AK2sc",