Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: b682fadee7
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (58 sloc) 3.08 KB
(ns plaza.rdf.schemas-test
(:use [plaza.rdf core sparql schemas] :reload-all)
(:use [plaza.rdf.implementations jena] :reload-all)
(:use [clojure.contrib.seq-utils :only [includes?]])
(:use [clojure.test]))
(use 'plaza.rdf.vocabularies.foaf)
(defonce *test-model* (make-rdfs-schema ["http://something/" "Good"]
:name {:uri "" :range :string}
:price {:uri ["" :price] :range :float}
:number {:uri :number :range :int}))
(deftest test-extend-schemas
(let [extended (extend-rdfs-schemas "" [*test-model*])]
(is (= "" (str (type-uri extended))))
(is (includes? (map #(str %1) (super-type-uris extended)) ""))
(is (includes? (map #(str %1) (super-type-uris extended)) "http://something/Good"))
(is (= "" (str (property-uri extended :name))))))
(deftest test-props
(is (= "http://something/Good" (str (type-uri *test-model*)))))
(deftest test-add-remove-prop
(do (let [modelp (-> *test-model*
(add-property :wadus "" :float)
(add-property :foo "" ""))
modelpp (-> modelp
(remove-property-by-uri "")
(remove-property-by-alias :wadus))]
(= :foo (property-alias modelp ""))
(= :wadus (property-alias modelp ""))
(is (nil? (property-alias modelpp :wadus)))
(is (nil? (property-alias modelpp :foo))))))
(deftest test-to-map
(let [m (to-map *test-model* [[:test ["" :name] "name"] [:test ["" :price] (d 120)] [:test :number (d 10)]])]
(is (= m {:name (rdf-resource "name") :price (d 120) :number (d 10)}))))
(deftest test-to-pattern
(let [p (to-pattern *test-model* [:name :price])]
(is (= 4 (count p)))
(is (= 2 (count (filter #(:optional (meta %1)) p))))))
(deftest test-to-pattern-2
(let [p (to-pattern *test-model* "" [:name :price])]
(is (= 4 (count p)))
(is (= 2 (count (filter #(:optional (meta %1)) p))))
(doseq [[s _p _o] p] (is (= "" (resource-id s))))))
(deftest test-property-uri
(is (= "" (str (property-uri *test-model* :name)))))
(deftest test-property-alias
(is (= :name (property-alias *test-model* ""))))
(deftest test-property-parse-value
(is (= 2 (parse-prop-value *test-model* :number "2"))))
(deftest test-schema-to-triples
(let [ts (to-rdf-triples foaf:Agent-schema)]
(is (= 37 (count ts)))))
(deftest test-parse-from-rdf
(let [ts (to-rdf-triples foaf:Agent-schema)
*m* (build-model)
_tmp (with-model *m* (model-add-triples ts))
parsed (parse-rdfs-schemas-from-model *m*)]
(is (= (sort (aliases foaf:Agent-schema)) (sort (aliases (first parsed)))))))
Jump to Line
Something went wrong with that request. Please try again.