more tests and investigation

This commit is contained in:
Michael Jerger 2023-07-26 09:18:49 +02:00
parent d4422ad19e
commit 06a1864b2f
2 changed files with 42 additions and 17 deletions

View file

@ -17,14 +17,6 @@
::owl/DeprecatedProperty ::owl/DeprecatedProperty
::xsd/anyURI)) ::xsd/anyURI))
;http://www.w3.org/ns/activitystreams#attachment
(s/def ::attachment
(s/and
::owl/ObjectProperty
::Class
::Link
::Object))
;http://www.w3.org/ns/activitystreams#result ;http://www.w3.org/ns/activitystreams#result
(s/def ::result (s/def ::result
(s/and (s/and
@ -33,26 +25,48 @@
::Object ::Object
::Link)) ::Link))
;http://www.w3.org/ns/activitystreams#attachment
(s/def ::attachment
(s/and
::owl/ObjectProperty
::Class
::Link
::Object))
;http://www.w3.org/ns/activitystreams#Relationship
;TODO: definition in progress
(s/def ::Relationship
(s/and (s/keys :opt-un [::object])))
;http://www.w3.org/ns/activitystreams#Activity ;http://www.w3.org/ns/activitystreams#Activity
;TODO: definition in progress ;TODO: definition in progress
(s/def ::Activity (s/def ::Activity
(s/and ::Object (s/and ::Object
(s/keys :opt-un [::result]))) (s/keys :opt-un [::result
::object])))
;http://www.w3.org/ns/activitystreams#Object ;http://www.w3.org/ns/activitystreams#object
;TODO: definition in progress (s/def ::object
(s/def ::Object (s/keys :opt-un [::id ::attachment])) (s/and
::owl/ObjectProperty
::Class
(s/or ::Object
::Link)))
;http://www.w3.org/ns/activitystreams#object
(s/def ::Object
(s/keys :opt-un [::id ::Class]))
;http://www.w3.org/ns/activitystreams#Link ;http://www.w3.org/ns/activitystreams#Link
;TODO: definition in progress ;TODO: definition in progress
(s/def ::Link (s/keys :opt-un [::id])) (s/def ::Link (s/keys :opt-un [::id]))
;TODO: There is no as:Class! Why do we need this? ;TODO: There is no as:Class! Why do we need this?
;Answer jem: I do not want to enhance owl/Class inline from here.
(s/def (s/def
::Class ::Class
(s/merge ::owl/Class (s/merge ::owl/Class
(s/keys :opt-un [::id]))) (s/keys :opt-un [::id ::object])))
;http://www.w3.org/ns/activitystreams#Like ;http://www.w3.org/ns/activitystreams#Like

View file

@ -14,16 +14,27 @@
(is (not (s/valid? ::sut/id nil))) (is (not (s/valid? ::sut/id nil)))
(is (not (s/valid? ::sut/id 2))) (is (not (s/valid? ::sut/id 2)))
(is (not (s/valid? ::sut/id "no-uri"))) (is (not (s/valid? ::sut/id "no-uri")))
(is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"]))) (is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"]))))
)
;TODO: where does the ability for a link reference come from ?
(deftest object-test
(is (s/valid? ::sut/object "http://example.org/posts/1"))
(is (s/valid? ::sut/object {:type "Note",
:content "A simple note"}))
(is (s/valid? ::sut/object ["http://example.org/posts/1",
{:type "Note",
:summary "A simple note",
:content "That is a tree."}])))
(deftest class-test
(is (s/valid? ::sut/Class "https://social.bla/alyssa/status/RANDOMHASH")))
(deftest result-test (deftest result-test
(is (s/valid? ::sut/result "https://social.bla/alyssa/result/RANDOMHASH")) (is (s/valid? ::sut/result "https://social.bla/alyssa/result/RANDOMHASH"))
(is (s/valid? ::sut/result {:type "http://www.types.example/flightstatus", :name "On Time"})) (is (s/valid? ::sut/result {:type "http://www.types.example/flightstatus", :name "On Time"}))
(is (s/valid? ::sut/result {:type "Link" :href "http://www.target.de"})) (is (s/valid? ::sut/result {:type "Link" :href "http://www.target.de"}))
(is (not (s/valid? ::sut/result nil))) (is (not (s/valid? ::sut/result nil)))
(is (not (s/valid? ::sut/result 47))) (is (not (s/valid? ::sut/result 47))))
)
;(deftest attachment-test ;(deftest attachment-test