예제 #1
0
파일: TestAsqc.py 프로젝트: timrdf/asqc
    def testGetRdfN3Data(self):
        class testOptions(object):
            verbose        = False
            rdf_data       = None
            format_rdf_in  = "N3"
        testRdfData = """
            @prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
            @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

            _:s rdfs:label "Example" ;
                rdfs:comment "This is really just an example." .
            """
        #
        options = testOptions()
        inpstr   = StringIO.StringIO(testRdfData)
        with SwitchStdin(inpstr):
            rdfgraph = asqc.getRdfData(options)
            assert len(rdfgraph) == 2
        #
        options = testOptions()
        options.rdf_data = ["test.n3"]
        rdfgraph = asqc.getRdfData(options)
        assert len(rdfgraph) == 2
        #
        options = testOptions()
        options.rdf_data = ["nosuchfile.n3"]
        rdfgraph = asqc.getRdfData(options)
        assert rdfgraph == None
        #
        return
예제 #2
0
파일: TestAsqc.py 프로젝트: timrdf/asqc
 def testGetRdfXmlData(self):
     class testOptions(object):
         verbose        = False
         rdf_data       = None
         format_rdf_in  = None
     testRdfData = """<?xml version="1.0" encoding="UTF-8"?>
         <rdf:RDF
           xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
           xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
         >
           <rdf:Description>
             <rdfs:label>Example</rdfs:label>
             <rdfs:comment>This is really just an example.</rdfs:comment>
           </rdf:Description>
         </rdf:RDF>
         """
     #
     options = testOptions()
     inpstr   = StringIO.StringIO(testRdfData)
     with SwitchStdin(inpstr):
         rdfgraph = asqc.getRdfData(options)
         assert len(rdfgraph) == 2
     #
     options = testOptions()
     options.rdf_data = ["test.rdf"]
     rdfgraph = asqc.getRdfData(options)
     assert len(rdfgraph) == 2
     #
     options = testOptions()
     options.rdf_data = ["nosuchfile.rdf"]
     rdfgraph = asqc.getRdfData(options)
     assert rdfgraph == None
     #
     return