From: Diane Trout Date: Tue, 27 Nov 2012 22:22:33 +0000 (-0800) Subject: Ignoring the missing type RDF error for the page under testing's url. X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=c79ee97e6c1345658e2a48d79081258249268936 Ignoring the missing type RDF error for the page under testing's url. 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 // 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. --- diff --git a/htsworkflow/frontend/experiments/test_experiments.py b/htsworkflow/frontend/experiments/test_experiments.py index e6d7484..631fb1b 100644 --- a/htsworkflow/frontend/experiments/test_experiments.py +++ b/htsworkflow/frontend/experiments/test_experiments.py @@ -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) diff --git a/htsworkflow/frontend/samples/test_samples.py b/htsworkflow/frontend/samples/test_samples.py index d64499d..0320c0a 100644 --- a/htsworkflow/frontend/samples/test_samples.py +++ b/htsworkflow/frontend/samples/test_samples.py @@ -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: @@ -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): diff --git a/htsworkflow/util/rdfinfer.py b/htsworkflow/util/rdfinfer.py index 1a0fb50..42957be 100644 --- a/htsworkflow/util/rdfinfer.py +++ b/htsworkflow/util/rdfinfer.py @@ -135,12 +135,14 @@ class Infer(object): prefix rdf: prefix rdfs: prefix owl: + prefix xhtmlv: select ?subject ?predicate ?object where { ?subject ?predicate ?object OPTIONAL { ?subject a ?class } FILTER(!bound(?class)) + FILTER(?predicate != xhtmlv:stylesheet) } """ query = RDF.SPARQLQuery(body)