@@ -172,3 +172,37 @@ def test_yaml_string(self):
172172 self .assertEqual (str (ydoc .date ), date )
173173 self .assertEqual (len (ydoc .sections ), 1 )
174174 self .assertEqual (ydoc .sections [0 ].name , sec_name )
175+
176+ def test_rdf_string (self ):
177+ author = "HPL"
178+ date = "1890-08-20"
179+ sec_name = "section name"
180+ sec_type = "section type"
181+ rdf_doc = u"""
182+ @prefix odml: <https://g-node.org/projects/odml-rdf#> .
183+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
184+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
185+ @prefix xml: <http://www.w3.org/XML/1998/namespace> .
186+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
187+
188+ odml:Hub odml:hasDocument <https://g-node.org/projects/odml-rdf#1c9ca24a-1d2c-40b6-a096-5a48efbd77d0> .
189+
190+ <https://g-node.org/projects/odml-rdf#1c9ca24a-1d2c-40b6-a096-5a48efbd77d0> a odml:Document ;
191+ odml:hasAuthor "%s" ;
192+ odml:hasDate "%s"^^xsd:date ;
193+ odml:hasSection <https://g-node.org/projects/odml-rdf#2abc6711-34e1-4102-8e3a-297fa4a3d19a> .
194+
195+ <https://g-node.org/projects/odml-rdf#2abc6711-34e1-4102-8e3a-297fa4a3d19a> a odml:Section ;
196+ odml:hasName "%s" ;
197+ odml:hasType "%s" .
198+ """ % (author , date , sec_name , sec_type )
199+
200+ rdoc = self .rdf_reader .from_string (rdf_doc , "turtle" )
201+
202+ self .assertEqual (rdoc [0 ].author , author )
203+ self .assertEqual (str (rdoc [0 ].date ), date )
204+ self .assertEqual (len (rdoc [0 ].sections ), 1 )
205+ self .assertEqual (rdoc [0 ].sections [0 ].name , sec_name )
206+
207+ with self .assertRaises (ValueError ):
208+ self .rdf_reader .from_string (rdf_doc )
0 commit comments