Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ __pycache__/
node_modules/
.tox
*.egg-info/
.pytest_cache
.pytest_cache
venv/
tdd/lib/*.js
tdd/lib/__pycache__/
5 changes: 3 additions & 2 deletions tdd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def get_id_description(uri, content_type, ontology):
if not resp.text.strip() or not (
re.search(r"^[^\#]", resp.text, re.MULTILINE)
): # because some SPARQL endpoint may send "# Empty file" as response
# raise IDNotFound()
abort(404)
from tdd.errors import IDNotFound

raise IDNotFound()
Comment thread
wiresio marked this conversation as resolved.
return resp.text
5 changes: 4 additions & 1 deletion tdd/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ def __init__(self, ld_content):


class IDNotFound(AppException):
title = "Not found"
title = "ID Not Found"
message = "The requested Thing Description ID was not found"
message_fr = "L'ID de description de chose demandé n'a pas été trouvé"
message_de = "Die angeforderte Thing Description ID wurde nicht gefunden"
status_code = 404


Expand Down
1 change: 1 addition & 0 deletions tdd/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Package providing access to built JavaScript assets via importlib.resources."""
8 changes: 4 additions & 4 deletions tdd/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ def custom(self, request, **kwargs):
@pytest.fixture
def mock_sparql_with_one_td(httpx_mock):
graph = SparqlGraph("smart_coffee_machine_init.nquads")
httpx_mock.add_callback(graph.custom)
httpx_mock.add_callback(graph.custom, is_reusable=True)


@pytest.fixture
def mock_sparql_with_one_expired_td(httpx_mock):
graph = SparqlGraph("smart_coffee_machine_expired.nquads")
httpx_mock.add_callback(graph.custom)
httpx_mock.add_callback(graph.custom, is_reusable=True)


@pytest.fixture
def mock_sparql_empty_endpoint(httpx_mock):
graph = SparqlGraph()
httpx_mock.add_callback(graph.custom)
httpx_mock.add_callback(graph.custom, is_reusable=True)


@pytest.fixture
def mock_sparql_17_things(httpx_mock):
graph = SparqlGraph("17_things.nquads")
httpx_mock.add_callback(graph.custom)
httpx_mock.add_callback(graph.custom, is_reusable=True)


@pytest.fixture
Expand Down
37 changes: 27 additions & 10 deletions tdd/tests/data/tdd-description.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
],
"@type": "ThingDirectory",
"title": "Thing Description Directory (TDD)",
"version": { "instance": "1.0.0-alpha" },
"securityDefinitions": { "no_sec": { "scheme": "nosec" } },
"version": {
"instance": "1.0.0-alpha"
},
"securityDefinitions": {
"no_sec": {
"scheme": "nosec"
}
},
"security": "no_sec",
"base": "http://localhost:5050",
"actions": {
Expand All @@ -26,7 +32,8 @@
"contentType": "application/td+json",
"response": {
"description": "Success response",
"htv:statusCodeValue": 201
"htv:statusCodeValue": 201,
"contentType": "application/x-empty"
},
"additionalResponses": [
{
Expand All @@ -50,7 +57,8 @@
"htv:fieldValue": ""
}
],
"htv:statusCodeValue": 201
"htv:statusCodeValue": 201,
"contentType": "application/x-empty"
},
"additionalResponses": [
{
Expand Down Expand Up @@ -79,7 +87,8 @@
"contentType": "application/td+json",
"response": {
"description": "Success response",
"htv:statusCodeValue": 204
"htv:statusCodeValue": 204,
"contentType": "application/x-empty"
},
"additionalResponses": [
{
Expand All @@ -96,7 +105,8 @@
"contentType": "application/merge-patch+json",
"response": {
"description": "Success response",
"htv:statusCodeValue": 204
"htv:statusCodeValue": 204,
"contentType": "application/x-empty"
},
"additionalResponses": [
{
Expand Down Expand Up @@ -124,7 +134,8 @@
"htv:methodName": "DELETE",
"response": {
"description": "Success response",
"htv:statusCodeValue": 204
"htv:statusCodeValue": 204,
"contentType": "application/x-empty"
},
"additionalResponses": [
{
Expand Down Expand Up @@ -174,7 +185,10 @@
"format": {
"title": "Format of answer, default to array",
"type": "string",
"enum": ["array", "collection"]
"enum": [
"array",
"collection"
]
},
"offset": {
"title": "Offset of the batch, default to 0",
Expand All @@ -201,7 +215,10 @@
"searchSPARQL": {
"description": "SPARQL semantic search",
"uriVariables": {
"query": { "title": "A valid SPARQL 1.1. query", "type": "string" }
"query": {
"title": "A valid SPARQL 1.1. query",
"type": "string"
}
},
"forms": [
{
Expand Down Expand Up @@ -241,4 +258,4 @@
]
}
}
}
}
Loading