Esempio n. 1
0
 def testQueryToStardog(self):
     main([
         "-e", "https://lindas.admin.ch/query", "-Q", testquery, "-m", POST
     ])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://classifications.data.admin.ch/canton/bl"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 2
0
    def testQueryWithEndpoint(self):
        main([
            "-Q",
            testquery,
            "-e",
            endpoint,
        ])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
            {
                "head": {
                    "link": [],
                    "vars": [
                        "x"
                    ]
                },
                "results": {
                    "distinct": false,
                    "ordered": true,
                    "bindings": [
                        {
                            "x": {
                                "type": "uri",
                                "value": "http://www.openlinksw.com/virtrdf-data-formats#default-iid"
                            }
                        }
                    ]
                }
            }
            """),
        )
Esempio n. 3
0
 def testQueryToLovFuseki(self):
     main([
         "-e", "https://lov.linkeddata.es/dataset/lov/sparql/", "-Q",
         testquery
     ])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://www.w3.org/2002/07/owl#someValuesFrom"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 4
0
 def testQueryToGraphDBEnterprise(self):
     main([
         "-e", "http://factforge.net/repositories/ff-news", "-Q", testquery
     ])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 5
0
 def testQueryToRDF4J(self):
     main([
         "-e",
         "http://vocabs.ands.org.au/repository/api/sparql/csiro_international-chronostratigraphic-chart_2018-revised-corrected",
         "-Q",
         testquery,
     ])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 6
0
    def testQueryWithFile(self):
        main(["-f", testfile, "-e", endpoint])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
            {
                "head": {
                    "link": [],
                    "vars": [
                        "pllabel"
                    ]
                },
                "results": {
                    "distinct": false,
                    "ordered": true,
                    "bindings": [
                        {
                            "pllabel": {
                                "type": "literal",
                                "xml:lang": "ja",
                                "value": "PARLOG"
                            }
                        }
                    ]
                }
            }
            """),
        )
Esempio n. 7
0
    def testQueryWithFileTSV(self):
        main(["-f", testfile, "-e", endpoint, "-F", "tsv"])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
                "pllabel"
                "PARLOG"\n
            """),
        )
Esempio n. 8
0
    def testQueryWithFileN3(self):
        main(["-f", testfile, "-e", endpoint, "-F", "n3"])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
            @prefix res: <http://www.w3.org/2005/sparql-results#> .
            @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
            _:_ a res:ResultSet .
            _:_ res:resultVariable "pllabel" .
            _:_ res:solution [
                  res:binding [ res:variable "pllabel" ; res:value "PARLOG"@ja ] ] .\n
            """),
        )
Esempio n. 9
0
    def testQueryWithFileRDFXML(self):
        main(["-f", testfile, "-e", endpoint, "-F", "rdf+xml"])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
            <?xml version="1.0" ?><sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
             <head>
              <variable name="pllabel"/>
             </head>
             <results distinct="false" ordered="true">
              <result>
               <binding name="pllabel"><literal xml:lang="ja">PARLOG</literal></binding>
              </result>
             </results>
            </sparql>
            """),
        )
Esempio n. 10
0
    def testQueryRDF(self):
        main([
            "-Q", "DESCRIBE <http://ja.wikipedia.org/wiki/SPARQL>", "-e",
            endpoint, "-F", "rdf"
        ])

        self.assertEqual(
            sys.stdout.getvalue(),
            textwrap.dedent("""\
            @prefix dc: <http://purl.org/dc/elements/1.1/> .
            @prefix foaf: <http://xmlns.com/foaf/0.1/> .

            <http://ja.dbpedia.org/resource/SPARQL> foaf:isPrimaryTopicOf <http://ja.wikipedia.org/wiki/SPARQL> .

            <http://ja.wikipedia.org/wiki/SPARQL> a foaf:Document ;
                dc:language "ja" ;
                foaf:primaryTopic <http://ja.dbpedia.org/resource/SPARQL> .


            """),
        )
Esempio n. 11
0
 def testQueryTo4store(self):
     main(["-e", "http://rdf.chise.org/sparql", "-Q", testquery])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "bnode",
                             "value": "b1f4d352f000000fc"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 12
0
 def testQueryToFuseki2V3_8(self):
     main(["-e", "http://zbw.eu/beta/sparql/stw/query", "-Q", testquery])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://www.w3.org/2004/02/skos/core"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 13
0
 def testQueryToFuseki2V3_6(self):
     main(["-e", "https://agrovoc.uniroma2.it/sparql/", "-Q", testquery])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://aims.fao.org/aos/agrovoc/"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 14
0
 def testQueryToBrazeGraph(self):
     main(["-e", "https://query.wikidata.org/sparql", "-Q", testquery])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "http://wikiba.se/ontology#Dump"
                         }
                     }
                 ]
             }
         }
         """),
     )
Esempio n. 15
0
 def testQueryToAllegroGraph(self):
     main(["-e", "https://mmisw.org/sparql", "-Q", testquery])
     self.assertEqual(
         sys.stdout.getvalue(),
         textwrap.dedent("""\
         {
             "head": {
                 "vars": [
                     "x"
                 ]
             },
             "results": {
                 "bindings": [
                     {
                         "x": {
                             "type": "uri",
                             "value": "https://mmisw.org/ont/~mjuckes/cmip_variables_alpha/rsdcs4co2"
                         }
                     }
                 ]
             }
         }
         """),
     )