-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #24
- Loading branch information
Showing
8 changed files
with
237 additions
and
6 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
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
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
Empty file.
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,37 @@ | ||
import aiohttp | ||
import unittest | ||
import uuid | ||
from aiohttp.test_utils import setup_test_loop, unittest_run_loop | ||
from os import environ as ENV | ||
|
||
from aiosparql.client import SPARQLClient | ||
from aiosparql.syntax import IRI | ||
|
||
__all__ = ['IntegrationTestCase', 'unittest_run_loop'] | ||
|
||
|
||
class IntegrationTestCase(unittest.TestCase): | ||
async def _create_client(self): | ||
return SPARQLClient( | ||
ENV.get("SPARQL_ENDPOINT", "http://localhost:8890/sparql"), | ||
update_endpoint=ENV.get("SPARQL_UPDATE_ENDPOINT"), | ||
crud_endpoint=ENV.get("SPARQL_UPDATE_ENDPOINT", | ||
"http://localhost:8890/sparql-graph-crud"), | ||
graph=self.graph) | ||
|
||
def _generate_random_graph(self): | ||
return IRI("http://aiosparql.org/%s" % uuid.uuid4().hex[:7]) | ||
|
||
def setUp(self): | ||
self.loop = setup_test_loop() | ||
self.graph = self._generate_random_graph() | ||
self.client = self.loop.run_until_complete(self._create_client()) | ||
|
||
def tearDown(self): | ||
try: | ||
self.loop.run_until_complete(self.client.delete()) | ||
except aiohttp.ClientResponseError as exc: | ||
if exc.code != 404: | ||
raise | ||
self.loop.run_until_complete(self.client.close()) | ||
self.loop.close() |
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,28 @@ | ||
from tests.integration.helpers import IntegrationTestCase, unittest_run_loop | ||
|
||
|
||
sample_data = """\ | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix dc: <http://purl.org/dc/elements/1.1/> . | ||
@prefix ex: <http://example.org/stuff/1.0/> . | ||
<http://www.w3.org/TR/rdf-syntax-grammar> | ||
dc:title "RDF/XML Syntax Specification (Revised)" ; | ||
ex:editor [ | ||
ex:fullname "Dave Beckett"; | ||
ex:homePage <http://purl.org/net/dajobe/> | ||
] . | ||
""" | ||
sample_format = "text/turtle" | ||
|
||
|
||
class Client(IntegrationTestCase): | ||
@unittest_run_loop | ||
async def test_crud(self): | ||
await self.client.put(sample_data, format=sample_format) | ||
await self.client.delete() | ||
await self.client.post(sample_data, format=sample_format) | ||
async with self.client.get(format="text/turtle") as res: | ||
self.assertEqual(res.status, 200) | ||
text = await res.text() | ||
self.assertIn("@prefix", text) |
Empty file.
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