This repository contains SPARQL queries and actions for working with Artsdata.
This repository includes both Ruby and Python unit tests for SPARQL queries.
Python tests are located in the tests/ directory and test SPARQL query syntax and basic functionality.
- Python 3.7 or higher
- pip (Python package manager)
To activate your Python virtual environment, run this command in your terminal from your project root:
source .venv/bin/activateThis assumes your virtual environment is in the .venv directory. After activation, you can run Python and pytest commands using the environment’s installed packages.
- Install Python dependencies:
pip install -r requirements.txtThis will install:
rdflib- RDF library for parsing and queryingpytest- Testing framework
To run all Python tests:
pytest tests/ -W ignore::DeprecationWarningTo run tests with verbose output:
pytest tests/ -v To run a specific test file:
pytest tests/test_sparql_syntax.py -vThe Python tests include:
-
test_sparql_syntax.py- Validates that SPARQL queries parse correctly- Tests syntax of SELECT queries
- Tests syntax of CONSTRUCT queries
- Tests the utility function for replacing federated SERVICE calls
-
test_sparql_basic_functionality.py- Tests basic SPARQL query functionality- Tests simple SELECT query execution
- Tests simple CONSTRUCT query execution
- Tests filtering with date conditions
- Tests optional properties in queries
-
tests/utils.py- Utility functions for testingreplace_federated_service_call()- Replaces Wikidata SERVICE blocks with test data
-
tests/fixtures/- Test data in Turtle (.ttl) format- Event data for testing queries
- Uses Turtle format to avoid network dependencies
Ruby tests are located in the ical/test/ directory.
- Ruby (version specified in
.ruby-version) - Bundler
- Install Ruby dependencies:
bundle installTo run all Ruby tests:
rake testOr use bundle:
bundle exec rake testSPARQL queries are located in two directories:
queries/- General SPARQL queries (mostly SELECT queries)ical/- SPARQL queries for iCal generation (mostly CONSTRUCT queries)
queries/upcoming_events_with_indigenous_agents.sparql- SELECT query for finding upcoming events with indigenous performers or organizersical/upcoming_events_with_indigenous_agents.sparql- CONSTRUCT query for building event data for iCal export
When adding new SPARQL queries:
- Add the
.sparqlfile to the appropriate directory (queries/orical/) - Add Python tests in
tests/to validate syntax - Add Ruby tests in
ical/test/if the query is for iCal generation - Run all tests to ensure they pass
[Add license information here]