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
4 changes: 2 additions & 2 deletions .github/workflows/dts-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- uses: actions/checkout@v4
name: Clone DTS-Validator
with:
repository: 'mromanello/DTS-validator'
ref: 'v0.2.0'
repository: 'distributed-text-services/validator'
ref: 'v0.2.3'
path: "dts-validator"

# Flask Server
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This library will:

## WebApp

You can try the webapp using `python -m dapitains.app.app`. It uses test files at the moment.
You can try the webapp using `python -m dapytains.app.app`. It uses test files at the moment.

## Guidelines

Expand Down
15 changes: 9 additions & 6 deletions dapytains/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

dotenv_flow(os.getenv("SERVER_ENV", "prod"))

CONTEXT_URL = "https://dtsapi.org/context/v1.0.json"
DTS_VERSION = "1.0"


def inject_json(collection: Collection, templates) -> Dict:
if collection.resource:
Expand Down Expand Up @@ -75,8 +78,8 @@ def collection_view(
return msg_4xx(f"nav parameter has a wrong value {nav}", code=400)

return Response(json.dumps({
"@context": "https://distributed-text-services.github.io/specifications/context/1-alpha1.json",
"dtsVersion": "1-alpha",
"@context": CONTEXT_URL,
"dtsVersion": DTS_VERSION,
**out,
"member": [
member.json(inject=inject_json(member, templates=templates))
Expand Down Expand Up @@ -153,8 +156,8 @@ def navigation_view(resource, ref, start, end, tree, down, templates: Dict[str,

# Start the response
out = {
"@context": "https://distributed-text-services.github.io/specifications/context/1-alpha1.json",
"dtsVersion": "1-alpha",
"@context": CONTEXT_URL,
"dtsVersion": DTS_VERSION,
"@type": "Navigation",
"@id": templates["navigation"].expand({
"ref": ref, "down": down, "start": start, "end": end, "tree": tree
Expand Down Expand Up @@ -220,8 +223,8 @@ def index_route():

return Response(
json.dumps({
"@context": "https://distributed-text-services.github.io/specifications/context/1-alpha1.json",
"dtsVersion": "1-alpha",
"@context": CONTEXT_URL,
"dtsVersion": DTS_VERSION,
"@id": f"{request.url_root}",
"@type": "EntryPoint",
"collection": collection_template.uri,
Expand Down
14 changes: 8 additions & 6 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

basedir = os.path.abspath(os.path.dirname(__file__))
BASE_URI = "http://localhost"
CONTEXT_URL = "https://dtsapi.org/context/v1.0.json"
DTS_VERSION = "1.0"


@pytest.fixture
Expand Down Expand Up @@ -51,10 +53,10 @@ def test_index(client):
response = client.get('/')
assert response.status_code == 200
assert response.get_json() == {
'@context': 'https://distributed-text-services.github.io/specifications/context/1-alpha1.json',
'@context': CONTEXT_URL,
'@id': 'http://localhost/',
'@type': 'EntryPoint',
'dtsVersion': '1-alpha',
'dtsVersion': DTS_VERSION,
'collection': 'http://localhost/collection/{?id}{&nav}',
'document': 'http://localhost/document/{?resource}{&ref,start,end,tree}',
'navigation': 'http://localhost/navigation/{?resource}{&ref,start,end,tree,down}',
Expand All @@ -67,11 +69,11 @@ def test_collection(client):
response = client.get(template.expand({}))
j = response.get_json()
assert {
'@context': 'https://distributed-text-services.github.io/specifications/context/1-alpha1.json',
'@context': CONTEXT_URL,
'@id': 'https://foo.bar/default',
'@type': 'Collection',
'collection': 'http://localhost/collection/?id=https%3A%2F%2Ffoo.bar%2Fdefault{&nav}',
'dtsVersion': '1-alpha',
'dtsVersion': DTS_VERSION,
'dublinCore': {'abstract': ['This is a perfect example of an absract.',
{'lang': 'fr',
'value': 'Et je peux traduire en français'}]},
Expand Down Expand Up @@ -133,11 +135,11 @@ def test_collection(client):
collection = uritemplate.URITemplate(j["member"][0]["collection"]).expand(
{"id": j["member"][0]["@id"]})
response = client.get(collection.replace(BASE_URI, ""))
assert {'@context': 'https://distributed-text-services.github.io/specifications/context/1-alpha1.json',
assert {'@context': CONTEXT_URL,
'@id': 'https://example.org/collection1',
'@type': 'Collection',
'collection': 'http://localhost/collection/?id=https%3A%2F%2Fexample.org%2Fcollection1{&nav}',
'dtsVersion': '1-alpha',
'dtsVersion': DTS_VERSION,
'dublinCore': {'creator': ['John Doe'],
'date': ['2023-08-24'],
'subject': ['History']},
Expand Down
Loading