[isidorus-cvs] r402 - trunk/src/unit_tests

Lukas Giessmann lgiessmann at common-lisp.net
Fri Apr 1 13:23:24 UTC 2011


Author: lgiessmann
Date: Fri Apr  1 09:23:24 2011
New Revision: 402

Log:
TM-SPARQL: finsihed the unit-tests for the special-uri tms:topicProperty

Modified:
   trunk/src/unit_tests/sparql_test.lisp

Modified: trunk/src/unit_tests/sparql_test.lisp
==============================================================================
--- trunk/src/unit_tests/sparql_test.lisp	(original)
+++ trunk/src/unit_tests/sparql_test.lisp	Fri Apr  1 09:23:24 2011
@@ -1787,7 +1787,6 @@
 	   r-1))))
 
 
-
 (test test-all-5
   "Tests the entire module with the file sparql_test.xtm"
   (with-fixture with-tm-filled-db ("data_base" *sparql_test.xtm*)
@@ -1817,9 +1816,51 @@
 	   r-1))))
 
 
+(test test-all-6
+  "Tests the entire module with the file sparql_test.xtm"
+  (with-fixture with-tm-filled-db ("data_base" *sparql_test.xtm*)
+    (tm-sparql:init-tm-sparql)
+    (let* ((q-1 (concat
+		 "PREFIX tms:<http://www.networkedplanet.com/tmsparql/>
+                  SELECT * WHERE {
+                   <http://some.where/tmsparql/author/goethe> tms:topicProperty ?props.
+                   ?subj1 tms:topicProperty <http://some.where/ii/goethe-untyped-name>.
+                   ?subj2 tms:topicProperty <http://some.where/ii/goethe-occ>"
+                 "}"))
+	   (r-1 (tm-sparql:result (make-instance 'TM-SPARQL:SPARQL-Query :query q-1)))
+	   (prop-ids
+	    (map 'list
+		 #'(lambda(prop)
+		     (if (item-identifiers prop :revision 0)
+			 (concat "<" (d:uri (first (item-identifiers
+						    prop :revision 0))) ">")
+			 (if (typep prop 'OccurrenceC)
+			     (concat "_:o" (write-to-string (elephant::oid prop)))
+			     (concat "_:n" (write-to-string (elephant::oid prop))))))
+		 (append (names (get-item-by-psi
+				 "http://some.where/tmsparql/author/goethe"
+				 :revision 0))
+			 (occurrences (get-item-by-psi
+				       "http://some.where/tmsparql/author/goethe"
+				       :revision 0))))))
+      (is-true (= (length r-1) 3))
+      (map 'list #'(lambda(item)
+		     (cond ((or (string= (getf item :variable) "subj1")
+				(string= (getf item :variable) "subj2"))
+			    (is (string=
+				 (first (getf item :result))
+				 "<http://some.where/tmsparql/author/goethe>")))
+			   ((string= (getf item :variable) "props")
+			    (is (= (length (getf item :result)) 8))
+			    (is-false (intersection prop-ids (getf item :result))))
+			   (t
+			    (is-true (format t "bad variable-name found")))))
+	   r-1))))
+
+
 
 
-;TODO: tms:topicProperty, tms:scope, tms:value, complex filter
+;TODO: tms:scope, tms:value, complex filter
 ;      <obj> <pred> <subj>
 ;      ?obj <pred> ?subj
 ;      <subj> ?pred ?obj




More information about the Isidorus-cvs mailing list