
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
"MustRD: Validate your SPARQL queries and transformations with precision and confidence, using BDD and Given-When-Then principles."
SPARQL is a powerful query language for RDF data, but how can you ensure your queries and transformations are doing what you intend? Whether you're working on a pipeline or a standalone query, certainty is key.
While RDF and SPARQL offer great flexibility, we noticed a gap in tooling to validate their behavior. We missed the robust testing frameworks available in imperative programming languages that help ensure your code works as expected.
With MustRD, you can:
MustRD is a Spec-By-Example ontology with a reference Python implementation, inspired by tools like Cucumber. It uses the Given-When-Then approach to define and validate SPARQL queries and transformations.
MustRD is designed to be triplestore/SPARQL engine agnostic, leveraging open standards to ensure compatibility across different platforms.
MustRD is not an alternative to SHACL. While SHACL validates data structures, MustRD focuses on validating data transformations and query results.
You define your specs in Turtle (.ttl
) or TriG (.trig
) files using the Given-When-Then approach:
Depending on the type of SPARQL query (CONSTRUCT, SELECT, INSERT/DELETE), MustRD runs the query and compares the results against the expectations defined in the spec.
Expectations can also be defined as:
You'll have a configuration .ttl
file, which acts as a suite of tests. It tells MustRD where to look for test specifications and any triplestore configurations you might have:
:test_example a :MustrdTest;
:hasSpecPath "test/specs/";
:hasDataPath "test/data/";
:hasPytestPath "example";
:triplestoreSpecPath "test/triplestore_config/triplestores.ttl";
:filterOnTripleStore triplestore:example_test .
In the directory specified by :hasSpecPath
, you'll have one or more .mustrd.ttl
files. These can be organized in a directory structure. MustRD collects them and reports results to your test runner.
:test_example :given [ a :FileDataset ;
:file "test/data/given.ttl" ] ;
:when [ a :TextSparqlSource ;
:queryText "SELECT ?s ?p ?o WHERE { ?s ?p ?o }" ;
:queryType :SelectSparql ] ;
:then [ a :OrderedTableDataset ;
:hasRow [ :variable "s" ; :boundValue "example:subject" ;
:variable "p" ; :boundValue "example:predicate" ;
:variable "o" ; :boundValue "example:object" ] ].
And you will have a 'test/data/given.ttl'
which contains the given ttl.
example:subject example:predicate example:object .
Run the test using the MustRD Pytest plugin:
poetry run pytest --mustrd --config=test/mustrd_configuration.ttl --md=render/github_job_summary.md
This will validate your SPARQL queries against the defined dataset and expected results, ensuring your transformations behave as intended.
You can refer to SPARQL inline, in files, or in Anzo Graphmarts, Steps, or Layers. See GETSTARTED.adoc
for more details.
We have a pytest plugin.
pip install mustrd
in it. "python.testing.pytestArgs": [
"--mustrd", "--md=junit/github_job_summary.md", "--config=test/test_config_local.ttl"
],
MustRD is a work in progress, built to meet the needs of our projects across multiple clients and vendor stacks. While we find it useful, it may not meet your needs out of the box.
We invite you to try it, raise issues, or contribute via pull requests. If you need custom features, contact us for consultancy rates, and we may prioritize your request.
Semantic Partners is a specialist consultancy in Semantic Technology. If you need more support, contact us at info@semanticpartners.com or mustrd@semanticpartners.com.
FAQs
A Spec By Example framework for RDF and SPARQL, Inspired by Cucumber.
We found that mustrd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.