summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIwan Aucamp <aucampia@gmail.com>2023-03-21 22:31:11 +0100
committerGitHub <noreply@github.com>2023-03-21 22:31:11 +0100
commitadf8eb2ec7de879fd4abb17f004796bd32ec8938 (patch)
tree89231151db2cbe76f110bc92a3b8c9056c7cc56d
parentfe1a8f8a3e3d03c39552fedba44b59b13d23814e (diff)
downloadrdflib-adf8eb2ec7de879fd4abb17f004796bd32ec8938.tar.gz
fix: add the `wgs` namespace binding back (#2294)
<https://github.com/RDFLib/rdflib/pull/1686> inadvertently removed the `wgs` prefix. This change adds it back. - Closes <https://github.com/RDFLib/rdflib/issues/2196>.
-rw-r--r--rdflib/namespace/__init__.py3
-rw-r--r--test/test_namespacemanager.py51
2 files changed, 53 insertions, 1 deletions
diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py
index 5bfac7c6..a68526e1 100644
--- a/rdflib/namespace/__init__.py
+++ b/rdflib/namespace/__init__.py
@@ -365,7 +365,7 @@ class NamespaceManager(object):
* binds all the namespaces shipped with RDFLib as DefinedNamespace instances
* all the core namespaces and all the following: brick, csvw, dc, dcat
* dcmitype, dcterms, dcam, doap, foaf, geo, odrl, org, prof, prov, qb, sdo
- * sh, skos, sosa, ssn, time, vann, void
+ * sh, skos, sosa, ssn, time, vann, void, wgs
* see the NAMESPACE_PREFIXES_RDFLIB object for the up-to-date list
* none:
* binds no namespaces to prefixes
@@ -914,4 +914,5 @@ _NAMESPACE_PREFIXES_RDFLIB = {
"time": TIME,
"vann": VANN,
"void": VOID,
+ "wgs": WGS,
}
diff --git a/test/test_namespacemanager.py b/test/test_namespacemanager.py
index 4d073b13..d688834e 100644
--- a/test/test_namespacemanager.py
+++ b/test/test_namespacemanager.py
@@ -172,6 +172,57 @@ def test_nman_bind_namespaces(
check_graph_ns(graph, expected_result)
+@pytest.mark.parametrize(
+ ["selector", "expected_bindings"],
+ [
+ (
+ "rdflib",
+ {
+ "brick": "https://brickschema.org/schema/Brick#",
+ "csvw": "http://www.w3.org/ns/csvw#",
+ "dc": "http://purl.org/dc/elements/1.1/",
+ "dcat": "http://www.w3.org/ns/dcat#",
+ "dcmitype": "http://purl.org/dc/dcmitype/",
+ "dcterms": "http://purl.org/dc/terms/",
+ "dcam": "http://purl.org/dc/dcam/",
+ "doap": "http://usefulinc.com/ns/doap#",
+ "foaf": "http://xmlns.com/foaf/0.1/",
+ "odrl": "http://www.w3.org/ns/odrl/2/",
+ "geo": "http://www.opengis.net/ont/geosparql#",
+ "org": "http://www.w3.org/ns/org#",
+ "owl": "http://www.w3.org/2002/07/owl#",
+ "prof": "http://www.w3.org/ns/dx/prof/",
+ "prov": "http://www.w3.org/ns/prov#",
+ "qb": "http://purl.org/linked-data/cube#",
+ "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
+ "sdo": "https://schema.org/",
+ "sh": "http://www.w3.org/ns/shacl#",
+ "skos": "http://www.w3.org/2004/02/skos/core#",
+ "sosa": "http://www.w3.org/ns/sosa/",
+ "ssn": "http://www.w3.org/ns/ssn/",
+ "time": "http://www.w3.org/2006/time#",
+ "vann": "http://purl.org/vocab/vann/",
+ "void": "http://rdfs.org/ns/void#",
+ "wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#",
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
+ "xml": "http://www.w3.org/XML/1998/namespace",
+ },
+ )
+ ],
+)
+def test_bound_namespaces_subset(
+ selector: Any, expected_bindings: Dict[str, str]
+) -> None:
+ graph = Graph(bind_namespaces=selector)
+ bound_namespaces = dict(
+ (key, str(value)) for key, value in graph.namespace_manager.namespaces()
+ )
+ assert (
+ expected_bindings.items() <= bound_namespaces.items()
+ ), f"missing items {expected_bindings.items() - bound_namespaces.items()}"
+
+
def test_compute_qname_no_generate() -> None:
g = Graph() # 'core' bind_namespaces (default)
with pytest.raises(KeyError):