Ignoring the missing type RDF error for the page under testing's url.
authorDiane Trout <diane@caltech.edu>
Tue, 27 Nov 2012 22:22:33 +0000 (14:22 -0800)
committerDiane Trout <diane@caltech.edu>
Tue, 27 Nov 2012 22:22:33 +0000 (14:22 -0800)
When testing the stylesheet gets attached to the pages url. All
the meaningful information about the sample or experiment still
gets added to the right <host>/<category>/<id> pages,
unfortunately that means the page url doesn't have a type which
caused _validate_types to toss an error.

I'd previously fixed it by testing for the error message and
filtering it out from the test code, but that didn't work on
ubuntu 10.04 as the error message changes slightly with the
older version of redland rdf.

This version changes the sparql query to ignore the case
where the predicate is a stylesheet and there's no type.

htsworkflow/frontend/experiments/test_experiments.py
htsworkflow/frontend/samples/test_samples.py
htsworkflow/util/rdfinfer.py

index e6d7484151149b4f7f7ce147cbacf046c28bb9d9..631fb1b6ab8ca1fde67246f97f6a3c2836346970 100644 (file)
@@ -649,9 +649,7 @@ class TestSequencer(TestCase):
         load_string_into_model(model, 'rdfa', response.content)
 
         errmsgs = list(inference.run_validation())
-        self.assertEqual(len(errmsgs), 2)
-        for errmsg in errmsgs:
-            self.assertEqual(errmsg, 'Missing type for: http://localhost/')
+        self.assertEqual(len(errmsgs), 0)
 
     def test_lane_with_rdf_validation(self):
         from htsworkflow.util.rdfhelp import add_default_schemas, \
@@ -673,6 +671,4 @@ class TestSequencer(TestCase):
         load_string_into_model(model, 'rdfa', response.content)
 
         errmsgs = list(inference.run_validation())
-        self.assertEqual(len(errmsgs), 2)
-        for errmsg in errmsgs:
-            self.assertEqual(errmsg, 'Missing type for: http://localhost/')
+        self.assertEqual(len(errmsgs), 0)
index d64499d2d911ef201aecb9000407e25964314205..0320c0ad318f8266ae776ac13b867209ea69866a 100644 (file)
@@ -181,9 +181,7 @@ class SampleWebTestCase(TestCase):
         from htsworkflow.util.rdfinfer import Infer
         add_default_schemas(model)
         inference = Infer(model)
-        ignored = {'Missing type for: http://localhost/'}
-        errmsgs = [msg for msg in inference.run_validation()
-                   if msg not in ignored ]
+        errmsgs = list(inference.run_validation())
         self.assertEqual(len(errmsgs), 0)
 
     def test_library_index_rdfa(self):
@@ -200,9 +198,7 @@ class SampleWebTestCase(TestCase):
         self.assertEqual(response.status_code, 200)
         load_string_into_model(model, 'rdfa', response.content)
 
-        ignored = {'Missing type for: http://localhost/'}
-        errmsgs = [msg for msg in inference.run_validation()
-                   if msg not in ignored ]
+        errmsgs = list(inference.run_validation())
         self.assertEqual(len(errmsgs), 0)
 
         body =  """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@@ -216,7 +212,7 @@ class SampleWebTestCase(TestCase):
                       ?species libns:species_name ?species_name . }
            OPTIONAL { ?library libns:name ?name . }
         }"""
-        bindings = {'library', 'library_id', 'name', 'species', 'species_name'}
+        bindings = set(['library', 'library_id', 'name', 'species', 'species_name'])
         query = RDF.SPARQLQuery(body)
         count = 0
         for r in query.execute(model):
index 1a0fb504181cdf4aed6ebf2aadf68271efbb5bb1..42957be4709a308ca8f563f6ab8b4cfbeedb043b 100644 (file)
@@ -135,12 +135,14 @@ class Infer(object):
         prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
         prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
         prefix owl: <http://www.w3.org/2002/07/owl#>
+        prefix xhtmlv: <http://www.w3.org/1999/xhtml/vocab#>
 
         select ?subject ?predicate ?object
         where {
           ?subject ?predicate ?object
           OPTIONAL { ?subject a ?class }
           FILTER(!bound(?class))
+          FILTER(?predicate != xhtmlv:stylesheet)
         }
         """
         query = RDF.SPARQLQuery(body)