1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.TagValidatorTest do
6 use Pleroma.DataCase, async: true
8 alias Pleroma.Web.ActivityPub.ObjectValidators.TagValidator
10 test "it validates an Edition" do
12 "@context" => "https://www.w3.org/ns/activitystreams",
14 "authors" => ["https://bookwyrm.com/author/3"],
16 "@context" => "https://www.w3.org/ns/activitystreams",
17 "name" => "Piranesi (2020, Bloomsbury Publishing)",
19 "url" => "https://bookwyrm.com/images/covers/9fd28af7-ebb8-4df3-80c8-28488fc5349f.jpeg"
23 "firstPublishedDate" => "",
25 "id" => "https://bookwyrm.com/book/10",
26 "isbn10" => "163557563X",
27 "isbn13" => "9781635575637",
28 "languages" => ["English"],
29 "librarythingKey" => "",
31 "openlibraryKey" => "OL28300471M",
33 "physicalFormat" => "",
34 "physicalFormatDetail" => "hardcover",
35 "publishedDate" => "2020-09-15T00:00:00+00:00",
36 "publishers" => ["Bloomsbury Publishing"],
40 "subjectPlaces" => [],
43 "title" => "Piranesi",
45 "work" => "https://bookwyrm.com/book/9"
48 assert %{valid?: true, changes: %{name: "Piranesi"}} = TagValidator.cast_and_validate(edition)
51 test "it should validate an author" do
53 "@context" => "https://www.w3.org/ns/activitystreams",
56 "bnfId" => "14603397h",
57 "born" => "1959-11-01T00:00:00+00:00",
59 "id" => "https://bookwyrm.com/author/3",
60 "isni" => "0000 0001 0877 1086",
61 "librarythingKey" => "",
62 "name" => "Susanna Clarke",
63 "openlibraryKey" => "OL1387961A",
65 "viafId" => "19931023",
69 assert %{valid?: true, changes: %{name: "Susanna Clarke"}} =
70 TagValidator.cast_and_validate(author)
73 test "it should validate a work" do
75 "@context" => "https://www.w3.org/ns/activitystreams",
76 "authors" => ["https://bookwyrm.com/author/3"],
78 "@context" => "https://www.w3.org/ns/activitystreams",
81 "url" => "https://bookwyrm.com/images/covers/e950ac10-feaf-4c3e-b2d3-de20d3a28329.jpeg"
83 "description" => "snipped",
85 "https://bookwyrm.com/book/12",
86 "https://bookwyrm.com/book/10",
87 "https://bookwyrm.com/book/14",
88 "https://bookwyrm.com/book/13",
89 "https://bookwyrm.com/book/11",
90 "https://bookwyrm.com/book/15"
92 "firstPublishedDate" => "",
94 "id" => "https://bookwyrm.com/book/9",
97 "librarythingKey" => "",
98 "openlibraryKey" => "OL20893680W",
99 "publishedDate" => "",
101 "seriesNumber" => "",
103 "subjectPlaces" => [],
104 "subjects" => ["English literature"],
106 "title" => "Piranesi",
110 assert %{valid?: true, changes: %{name: "Piranesi"}} = TagValidator.cast_and_validate(work)