-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: implement unit tests for check_query
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |