def _store_provenance(self, wf_base_uri):
     """Store resulting provenance in the Graph Store."""
     # We need to store provenance in a separate graph for each context
     # And also in the global Provenance graph
     prov_doc = create_uri(ATTXPROVURL, wf_base_uri)
     storage = GraphStore()
     storage._graph_add(prov_doc, self.graph.serialize(format='turtle'))
 def on_post(self, req, resp, parsed):
     """Execution of the POST update query request."""
     fuseki = GraphStore()
     resp.data = json.dumps(
         fuseki._graph_add(parsed['namedGraph'], parsed['triples']))
     resp.content_type = 'application/json'
     resp.status = falcon.HTTP_200
     app_logger.info('Finished operations on /graph/update POST Request.')
    def test_graph_add(self):
        """Test update graph."""
        url = "http://data.hulib.helsinki.fi/attx/strategy"
        graph_data = "<http://example/egbook3> <http://purl.org/dc/elements/1.1/title>  \"This is an example title\""
        with open('tests/resources/graph_add_response.json') as datafile:
            response_data = json.load(datafile)

        def request_callback(request):
            """Request callback for drop graph."""
            headers = {
                'content-type': "application/json",
                'cache-control': "no-cache"
            }
            return (200, headers, json.dumps(response_data))

        responses.add_callback(
            responses.POST,
            "{0}/data?graph={1}".format(self.request_address, url),
            callback=request_callback,
            content_type='text/turtle',
        )
        fuseki = GraphStore()
        result = fuseki._graph_add(url, graph_data)
        assert (result == json.dumps(response_data))
 def _store_provenance_graph(self):
     """Store resulting provenance in the Graph Store."""
     storage = GraphStore()
     storage._graph_add(ATTXProv, self.graph.serialize(format='turtle'))
 def test_graph_add_bad(self):
     """Test ConnectionError graph update on graph endpoint."""
     fuseki = GraphStore()
     with self.assertRaises(ConnectionError):
         fuseki._graph_add("default", "")