Emulating a SPARQL endpoint for unit tests

75 views
Skip to first unread message

Boris Pelakh

unread,
Aug 2, 2021, 10:23:13 AM8/2/21
to rdflib-dev
I wrote once a pytest fixture that intercepted HTTP requests and emulated a SPARQL endpoint for use in unit tests using an in-memory RDFLIB Graph. Unfortunately that code is no longer accessible (buried inside a proprietary app), and before I reproduced the work, I was wondering if anyone else has created a similar beast. 

Nicholas Car

unread,
Aug 3, 2021, 6:54:18 AM8/3/21
to rdfli...@googlegroups.com
Hi Boris, I have not done this but I think it would be a very handy thing to have, so count me in on assisting with rebuilding, if noone has one to directly reuse.

Nick

On Tue, Aug 3, 2021 at 12:23 AM Boris Pelakh <pel...@gmail.com> wrote:
I wrote once a pytest fixture that intercepted HTTP requests and emulated a SPARQL endpoint for use in unit tests using an in-memory RDFLIB Graph. Unfortunately that code is no longer accessible (buried inside a proprietary app), and before I reproduced the work, I was wondering if anyone else has created a similar beast. 

--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/711590fb-b2c9-42dc-a5a1-cd68860ee335n%40googlegroups.com.

Boris Pelakh

unread,
Aug 4, 2021, 4:55:37 PM8/4/21
to rdflib-dev
I have the initial skeleton built (https://github.com/sa-bpelakh/sparql-endpoint-fixture), but ran into an issue with requests_mock (see https://stackoverflow.com/questions/68655684/mocked-urls-not-being-forward-to-handler-when-using-requests-mock-in-another-fix). I will continue on it as I get bandwidth, still need to add the graph protocol functionality as well as figure out how to inject externally-provided 'from <graph>' and 'from named <graph>' into queries.

Nicholas Car

unread,
Aug 9, 2021, 2:49:27 AM8/9/21
to rdfli...@googlegroups.com
Great Boris. You can bump the dependency from rdflib>5.0.0 to rdflib>=6.0.0!

If you want to add this to the RDFlib family of repositories, like your pyTARQL, please let me know and I'll create a repo for you. If you do though, could you convert to a BSD 3-clause license? That would keep the license the same as the main RDFlib license. and preferably the same change for pyTARQL!

Thanks,

Nick

Boris Pelakh

unread,
Aug 15, 2021, 9:18:46 AM8/15/21
to rdflib-dev
So, I finally got it working with both requests and SPARQLWrapper, and deployed a test copy at https://test.pypi.org/project/sparql-endpoint-fixture/. Also changed the license to BSD-3. Look over the docs, and if you don't see any glaring holes, we can migrate it into the RDFlib repo and push to the release PyPi. I am guessing that the GitHub Action currently verifying and pushing to PyPi will have to be adjusted to follow RDFlib conventions.

Nicholas Car

unread,
Sep 6, 2021, 6:22:44 AM9/6/21
to rdfli...@googlegroups.com
Hi Boris,

That's a very simple, and very neatly coded system! Nice use of the SPARQL algebra too, rather than any string processing.

Code looks good, happy to have it in rdflib on GitHub. Once it is, I'll try and replace some of the current main set of rdflib tests with it as we often just skip the SPARQL tests since we can't be bothered to run a triplestore for them (yes, lazy).

A couple of trivial code things:
Cheers,

Nick

Reply all
Reply to author
Forward
0 new messages