Esempio n. 1
0
def query(user,
          repo,
          query_name,
          subdir=None,
          spec_url=None,
          sha=None,
          content=None):
    """Execute SPARQL query for a specific grlc-generated API endpoint"""
    glogger.info(
        "-----> Executing call name at /{}/{}/{}/{} on commit {}".format(
            user, repo, subdir, query_name, sha))
    glogger.debug("Request accept header: " + request.headers["Accept"])

    requestArgs = request.args
    acceptHeader = request.headers['Accept']
    requestUrl = request.url
    formData = request.form

    query_response, status, headers = utils.dispatch_query(
        user,
        repo,
        query_name,
        subdir,
        spec_url,
        sha=sha,
        content=content,
        requestArgs=requestArgs,
        acceptHeader=acceptHeader,
        requestUrl=requestUrl,
        formData=formData)
    if isinstance(query_response, list):
        query_response = jsonify(query_response)

    return make_response(query_response, status, headers)
Esempio n. 2
0
    def test_dispatch_query(self, mock_get, mock_loader):
        mock_get.return_value = self.setMockGetResponse()
        mock_loader.return_value = self.loader

        resp, status, headers = utils.dispatch_query(None, None, 'test-projection', requestArgs={'id': 'http://dbpedia.org/resource/Frida_Kahlo'})

        self.validateTestResponse(resp)
        self.assertNotEqual(status, 404)