OK, this actually *is* working...

At least partly. Faults are found in all of the documents in the activitystreams-test-documents suite, but this is because

1. five have no `@context` value;
2. the remaining two hundred all consistently use 'http' as the protocol part of the `@context` URI, but the specification requires `https`...

I am picking up other faults and some (perhaps all) of these may be errors in my code rather than in the test documents, but I am heading in the right direction.
This commit is contained in:
Simon Brooke 2023-01-08 22:29:55 +00:00
parent 98e3c7b4e7
commit 2893d83c15
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
2 changed files with 28 additions and 7 deletions

View file

@ -19,7 +19,11 @@
(def ^:const activitystreams-context-uri (def ^:const activitystreams-context-uri
"The URI of the context of an ActivityStreams object is expected to be this "The URI of the context of an ActivityStreams object is expected to be this
literal string." literal string.
**NOTE THAT** the URI actually used in the published suite of
activitystreams-test-documents use this URI with 'http' rather than
'https' as the property part, but the spec itself specifies 'https'."
"https://www.w3.org/ns/activitystreams") "https://www.w3.org/ns/activitystreams")
(def ^:const actor-types (def ^:const actor-types

View file

@ -4,17 +4,24 @@
[clojure.java.io :refer [file]] [clojure.java.io :refer [file]]
[clojure.walk :refer [keywordize-keys]] [clojure.walk :refer [keywordize-keys]]
[dog-and-duck.quack.picky.objects :refer [dog-and-duck.quack.picky.objects :refer
[object-faults]] [object-faults properties-faults]]
[dog-and-duck.quack.picky.utils :refer [concat-non-empty]])) [dog-and-duck.quack.picky.utils :refer [concat-non-empty
filter-severity]]))
(def files (filter
#(and (.isFile %) (.endsWith (.getName %) ".json"))
(file-seq (file "resources/activitystreams-test-documents"))))
(def r (def r
(remove (remove
nil? empty?
(map (map
#(try #(try
(let [contents (read-str (slurp %)) (let [contents (read-str (slurp %))
faults (cond (map? contents) (object-faults faults (cond (map? contents) (filter-severity
(object-faults
(keywordize-keys contents)) (keywordize-keys contents))
:should)
;; (coll? contents) (apply ;; (coll? contents) (apply
;; concat-non-empty ;; concat-non-empty
;; (map (fn [obj] ;; (map (fn [obj]
@ -22,7 +29,7 @@
;; (keywordize-keys obj))) ;; (keywordize-keys obj)))
;; contents)) ;; contents))
)] )]
(when-not (nil? faults) (when-not (empty? faults)
[(.getName %) faults])) [(.getName %) faults]))
(catch Exception any (catch Exception any
[(.getName %) (str "Exception " [(.getName %) (str "Exception "
@ -32,3 +39,13 @@
(filter (filter
#(and (.isFile %) (.endsWith (.getName %) ".json")) #(and (.isFile %) (.endsWith (.getName %) ".json"))
(file-seq (file "resources/activitystreams-test-documents")))))) (file-seq (file "resources/activitystreams-test-documents"))))))
(count (filter-severity (object-faults (keywordize-keys (read-str (slurp "resources/activitystreams-test-documents/vocabulary-ex189-jsonld.json")))) :critical))
(count (filter
#(and (.isFile %) (.endsWith (.getName %) ".json"))
(file-seq (file "resources/activitystreams-test-documents"))))
(count r)
(last r)
(clojure.pprint/pprint (last r))