Ejemplo n.º 1
0
class InsertSparqlTest(unittest.TestCase):
    def setUp(self):

        print "getting myspace data"
        self.short_url_artist = "kurtisrandom"
        self.uid_artist = "30650288"
        self.A = MyspaceScrape(uid=self.uid_artist)
        self.A.run()

    def test_insert_sparql(self):
        print "inserting"
        # cursor = self.connect.cursor()
        self.A.insert_sparql()
        print "checking insert"

        res = TripleStore().query(
            """SELECT ?same WHERE { <http://dbtune.org/myspace/uid/30650288> <http://www.w3.org/2002/07/owl#sameAs> ?same . }  """
        )
        # print res
        same = res[0]["same"]
        assert rdflib.URIRef("http://dbtune.org/myspace/kurtisrandom") == same, "wrong sameAs result: " + str(same)

        # cursor.close()

    def tearDown(self):
        TripleStore().delete_graph(GRAPH)
Ejemplo n.º 2
0
    def default(self, uid):
        if uid.endswith(".rdf"):
            # serve the data
            cherrypy.response.headers["Content-Type"] = "application/rdf+xml; charset=UTF-8;"

            M = MyspaceScrape(uid=uid.rsplit(".rdf")[0])
            M.run()
            if SPARQL_ENABLED:
                try:
                    M.insert_sparql()
                except Exception, err:
                    print "ERROR insert_sparql() failed" + err
            return M.serialize()