Skip to content

Commit

Permalink
test: implement unit tests for check_query
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-pl committed Jan 23, 2025
1 parent 2177a12 commit fcb54a9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/unit/tests_checkers/test_query_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Unit test for rdfproxy.utils.checkers.query_checker."""

import pytest

from rdfproxy.utils._exceptions import QueryParseException, UnsupportedQueryException
from rdfproxy.utils.checkers.query_checker import check_query


fail_queries_parse_exception: list[str] = [
"select * where {?s ?p ?o ",
"select * where {?s ?p}",
"select ? where {?s ?p ?o}",
"select * where {?s ?p ?o } limit",
"""
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
select * where {?s ?p ?o } limit
""",
]
fail_queries_unsupported: list[str] = [
"ask where {?s ?p ?o}",
"""
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
ask where {?s ?p ?o}
""",
"construct {?s ?p ?o} where {?s ?p ?o}",
"describe ?s where {?s ?p ?o}",
]


@pytest.mark.parametrize("query", fail_queries_parse_exception)
def test_check_query_parse_exception(query):
with pytest.raises(QueryParseException):
check_query(query)


@pytest.mark.parametrize("query", fail_queries_unsupported)
def test_check_query_unsupported(query):
with pytest.raises(UnsupportedQueryException):
check_query(query)

0 comments on commit fcb54a9

Please sign in to comment.