Huge amounts of (unfinished, not working) work on picky validator.

This commit is contained in:
Simon Brooke 2022-12-22 22:35:50 +00:00
parent 21220970a8
commit 3f35c5e293
9 changed files with 399 additions and 122 deletions

View file

@ -4,6 +4,22 @@
filter-severity object-faults
persistent-object-faults]]))
;;; Copyright (C) Simon Brooke, 2022
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License
;;; as published by the Free Software Foundation; either version 2
;;; of the License, or (at your option) any later version.
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
(deftest object-fault-tests
(let [perfect {(keyword "@context") activitystreams-context-uri
:id "https://somewhere.out.there/object/14323:1671654380083"

View file

@ -1,10 +1,10 @@
(ns dog-and-duck.quack.quack-test
(:require [clojure.test :refer [deftest is testing]]
[dog-and-duck.quack.picky :refer [activitystreams-context-uri
context?]]
[dog-and-duck.quack.quack :refer [actor? actor-type?
[dog-and-duck.quack.picky :refer [activitystreams-context-uri
context? context-key]]
[dog-and-duck.quack.quack :refer [actor? actor-type?
object? ordered-collection-page?
persistent-object?
persistent-object?
verb-type?]]
[dog-and-duck.scratch.parser :refer [clean]]))
@ -32,7 +32,7 @@
(let [expected true
actual (object? {:type "Test"})]
(is (= actual expected)))
(let [expected false
(let [expected true
actual (object?
(first
(clean
@ -117,25 +117,31 @@
(let [expected true
actual (context? [activitystreams-context-uri {:foo "bar"}])]
(is (= actual expected)
"order of elements within a context should not matter"))
))
"order of elements within a context should not matter"))))
(deftest actor-test
(testing "identification of actors"
(let [expected false
actual (actor? (-> "resources/activitystreams-test-documents/simple0008.json" slurp clean first))]
(is (= actual expected) "A Note is not an actor"))
(let [expected true
(let [expected false
actual (actor? (-> "resources/activitystreams-test-documents/simple0020.json" slurp clean first :actor))]
(is (= actual expected) "A Person is an actor"))
))
(is (= actual expected) "The Person in this file is not valid as an actor, because it lacks a context."))
(let [o (assoc (-> "resources/activitystreams-test-documents/simple0020.json"
slurp
clean
first
:actor)
context-key activitystreams-context-uri)
expected true
actual (actor? o)]
(is (= actual expected) (str "The Person from this file is now valid as an actor, because it has a context." o)))))
(deftest ordered-collection-page-test
(testing "identification of ordered collection pages."
(let [expected false
actual (ordered-collection-page? (-> "resources/activitystreams-test-documents/simple0020.json" slurp clean first))]
(is (= actual expected) "A Note is not an ordered collection page."))
(let [expected true
actual (ordered-collection-page? (-> "resources/test_documents/outbox_page.json" slurp clean first))]
(is (= actual expected) "A page from an outbox is an ordered collection page."))
))
(let [expected true
actual (ordered-collection-page? (-> "resources/test_documents/outbox_page.json" slurp clean first))]
(is (= actual expected) "A page from an outbox is an ordered collection page."))))