Skip to content

Commit

Permalink
Tests for #919
Browse files Browse the repository at this point in the history
  • Loading branch information
aucampia committed Jun 27, 2021
1 parent 237537d commit 2ef3897
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rdflib/plugins/stores/sparqlconnector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import logging
from rdflib.term import Literal
from typing import Optional, TYPE_CHECKING, Tuple, Union
import typing_extensions
from urllib.request import urlopen, Request
from urllib.parse import urlencode
from urllib.error import HTTPError, URLError
Expand All @@ -11,6 +14,8 @@

log = logging.getLogger(__name__)

if TYPE_CHECKING:
import typing_extensions as te

class SPARQLConnectorException(Exception):
pass
Expand All @@ -33,11 +38,11 @@ class SPARQLConnector(object):

def __init__(
self,
query_endpoint=None,
update_endpoint=None,
returnFormat="xml",
method="GET",
auth=None,
query_endpoint: Optional[str]=None,
update_endpoint: Optional[str]=None,
returnFormat: str="xml",
method: "te.Literal['GET', 'POST', 'POST_FORM']" ="GET",
auth: Optional[Tuple[str, str]]=None,
**kwargs
):
"""
Expand Down
29 changes: 29 additions & 0 deletions test/test_sparqlconnector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import ClassVar
from rdflib.graph import Graph
from .testutils import ServedSimpleHTTPMock
import unittest

class TestStore(unittest.TestCase):
query_path: ClassVar[str]
update_path: ClassVar[str]
httpmock: ClassVar[ServedSimpleHTTPMock]

@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.httpmock = ServedSimpleHTTPMock()
cls.query_path = f"{cls.httpmock.url}/db/sparql"
cls.update_path = f"{cls.httpmock.url}/db/update"

@classmethod
def tearDownClass(cls) -> None:
super().tearDownClass()
cls.httpmock.stop()

def setUp(self):
self.httpmock.reset()
self.graph = Graph(store="SPARQLUpdateStore")
self.graph.open(self.path, create=True)

def tearDown(self):
self.graph.close()

0 comments on commit 2ef3897

Please sign in to comment.