Lint tests
This commit is contained in:
0
glowtables/tests/__init__.py
Normal file
0
glowtables/tests/__init__.py
Normal file
@ -12,6 +12,10 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with
|
# You should have received a copy of the GNU Affero General Public License along with
|
||||||
# this program. If not, see <http://www.gnu.org/licenses/>.
|
# this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
"""pytest fixtures"""
|
||||||
|
|
||||||
|
# pylint: disable=redefined-outer-name
|
||||||
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -21,6 +25,8 @@ from glowtables.sparql import SparqlBackend
|
|||||||
|
|
||||||
|
|
||||||
class RdflibSparqlBackend(SparqlBackend):
|
class RdflibSparqlBackend(SparqlBackend):
|
||||||
|
"""Mock SPARQL backend that queries a local rdflib graph."""
|
||||||
|
|
||||||
def __init__(self, graph: rdflib.Graph):
|
def __init__(self, graph: rdflib.Graph):
|
||||||
self._graph = graph
|
self._graph = graph
|
||||||
|
|
||||||
@ -30,10 +36,12 @@ class RdflibSparqlBackend(SparqlBackend):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def rdflib_graph():
|
def rdflib_graph() -> rdflib.Graph:
|
||||||
|
"""Returns an empty rdflib graph."""
|
||||||
return rdflib.Graph()
|
return rdflib.Graph()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def rdflib_sparql(rdflib_graph: rdflib.Graph):
|
def rdflib_sparql(rdflib_graph: rdflib.Graph) -> RdflibSparqlBackend:
|
||||||
|
"""Returns a SPARQL backend instance for ``rdflib_graph``."""
|
||||||
return RdflibSparqlBackend(rdflib_graph)
|
return RdflibSparqlBackend(rdflib_graph)
|
||||||
|
@ -19,8 +19,10 @@ import rdflib
|
|||||||
|
|
||||||
from glowtables.table import Language, LiteralField, Table
|
from glowtables.table import Language, LiteralField, Table
|
||||||
|
|
||||||
|
from .conftest import RdflibSparqlBackend
|
||||||
|
|
||||||
def test_single_literal(rdflib_sparql) -> None:
|
|
||||||
|
def test_single_literal(rdflib_sparql: RdflibSparqlBackend) -> None:
|
||||||
name_field = LiteralField(
|
name_field = LiteralField(
|
||||||
"display_name",
|
"display_name",
|
||||||
{Language("en"): "Name"},
|
{Language("en"): "Name"},
|
||||||
@ -44,7 +46,7 @@ def test_single_literal(rdflib_sparql) -> None:
|
|||||||
rdflib_sparql.query(table.sparql())
|
rdflib_sparql.query(table.sparql())
|
||||||
|
|
||||||
|
|
||||||
def test_two_literals(rdflib_sparql) -> None:
|
def test_two_literals(rdflib_sparql: RdflibSparqlBackend) -> None:
|
||||||
name_field = LiteralField(
|
name_field = LiteralField(
|
||||||
"display_name",
|
"display_name",
|
||||||
{Language("en"): "Name"},
|
{Language("en"): "Name"},
|
||||||
@ -74,7 +76,7 @@ def test_two_literals(rdflib_sparql) -> None:
|
|||||||
rdflib_sparql.query(table.sparql())
|
rdflib_sparql.query(table.sparql())
|
||||||
|
|
||||||
|
|
||||||
def test_default_value(rdflib_sparql) -> None:
|
def test_default_value(rdflib_sparql: RdflibSparqlBackend) -> None:
|
||||||
name_field = LiteralField(
|
name_field = LiteralField(
|
||||||
"display_name",
|
"display_name",
|
||||||
{Language("en"): "Name"},
|
{Language("en"): "Name"},
|
||||||
|
@ -54,6 +54,9 @@ disable = [
|
|||||||
# flake8 does it already:
|
# flake8 does it already:
|
||||||
"line-too-long",
|
"line-too-long",
|
||||||
]
|
]
|
||||||
|
ignore-paths = [
|
||||||
|
"glowtables/tests/.*_test.py"
|
||||||
|
]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
python_files = "*_test.py"
|
python_files = "*_test.py"
|
||||||
|
Reference in New Issue
Block a user