How to use the grlc.utils.dispatchSPARQLQuery function in grlc

To help you get started, we’ve selected a few grlc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CLARIAH / grlc / tests / test_utils.py View on Github external
def test_projection(self, mock_get):
        mock_get.return_value = self.setMockGetResponse()

        rq, _ = self.loader.getTextForName('test-projection')
        resp, status, headers = utils.dispatchSPARQLQuery(rq, self.loader, content=None, requestArgs={'id': 'http://dbpedia.org/resource/Frida_Kahlo'},
                                                          acceptHeader='application/json',
                                                          requestUrl='http://mock-endpoint/sparql', formData={})
        self.validateTestResponse(resp)
github CLARIAH / grlc / tests / test_gquery.py View on Github external
def test_sparql_transformer(self):
        rq, _ = self.loader.getTextForName('test-json')

        endpoint, _ = gquery.guess_endpoint_uri(rq, self.loader)
        self.assertEqual('http://dbpedia.org/sparql', endpoint, 'Should match endpoint in test-json.json')

        resp, status, headers = utils.dispatchSPARQLQuery(rq, self.loader, content=None, requestArgs={},
                                                          acceptHeader='application/json',
                                                          requestUrl='http://', formData={})
        self.assertEqual(status, 200)
        self.assertIsInstance(resp, list)
        self.assertIn('id', resp[0])
github CLARIAH / grlc / tests / test_utils.py View on Github external
"xml:lang": "en",
                            "value": "xsd:boolean"
                        }
                    }]
            }
        }

        mock_get.return_value = Mock(ok=True)
        mock_get.return_value.headers = {'Content-Type': 'application/json'}
        mock_get.return_value.text = json.dumps(mock_json)

        rq, _ = self.loader.getTextForName('test-json')

        self.assertIn('proto', rq)

        resp, status, headers = utils.dispatchSPARQLQuery(rq, self.loader, content=None, requestArgs={},
                                                          acceptHeader='application/json',
                                                          requestUrl='http://mock-endpoint/sparql', formData={})
        self.assertEqual(status, 200)
        self.assertIsInstance(resp, list)
        self.assertIn('http', resp[0]['id'])