Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2164 #2165

Merged
merged 7 commits into from
Dec 24, 2022
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: 3 additions & 2 deletions rdflib/plugins/shared/jsonld/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def _prep_sources(
new_ctx = self._fetch_context(
source, source_doc_base, referenced_contexts
)
new_base = base
if new_ctx is None:
continue
else:
Expand All @@ -412,7 +413,7 @@ def _prep_sources(
# if base is not None, then source_doc_base won't be
# none due to how it is assigned.
assert source_doc_base is not None
base = urljoin(source_doc_base, source_url)
new_base = urljoin(source_doc_base, source_url)
source = new_ctx

if isinstance(source, dict):
Expand All @@ -422,7 +423,7 @@ def _prep_sources(

if isinstance(source, list):
self._prep_sources(
base, source, sources, referenced_contexts, source_url
new_base, source, sources, referenced_contexts, source_url
)
else:
sources.append((source_url, source))
Expand Down
2 changes: 2 additions & 0 deletions test/jsonld/local-suite/contexts/import1.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 2 additions & 0 deletions test/jsonld/local-suite/contexts/import2.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
10 changes: 9 additions & 1 deletion test/jsonld/local-suite/manifest.jsonld
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": "http://json-ld.org/test-suite/context.jsonld",
"@context": "h2p://json-ld.org/test-suite/context.jsonld",
"@id": "",
"@type": "mf:Manifest",
"name": "RDFLib-jsonld local test suite",
Expand All @@ -19,6 +19,14 @@
"purpose": "Expanding urn IRIs recursively. Issue #75",
"input": "sample-urn-in.jsonld",
"expect": "sample-urn-out.nq"
},
{
"@id": "#toRdf-twoimports",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
"name": "JSON-LD parser doesn't restore root directory",
"purpose": "Multiple @id aliases. Issue #2164",
"input": "toRdf-twoimports-in.jsonld",
"expect": "toRdf-twoimports-out.nq"
}
]
}
6 changes: 6 additions & 0 deletions test/jsonld/local-suite/toRdf-twoimports-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": [
"contexts/import1.jsonld",
"contexts/import2.jsonld"
]
}
Empty file.
7 changes: 6 additions & 1 deletion test/jsonld/test_localsuite.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import json
from os import chdir, getcwd
from os import path as p
from pathlib import Path

import pytest

from rdflib.term import URIRef

from . import runner

TC_BASE = "https://rdflib.github.io/rdflib-jsonld/local-testsuite/"
# TODO FIXME: We should be using this URI instead of a file URI, but as there is
# no way to customize URI loading yet this will not work, so instead TC_BASE is
# set to a file-uri further down.
# TC_BASE = "https://rdflib.github.io/rdflib-jsonld/local-testsuite/"

TC_BASE = (Path(__file__).parent / "local-suite").absolute().as_uri() + "/"

testsuite_dir = p.join(p.abspath(p.dirname(__file__)), "local-suite")

Expand Down