fix: restore the 6.1.1 default bound namespaces (#2313) · RDFLib/rdflib@57bb428 (original) (raw)
`@@ -33,9 +33,41 @@ def test_core_prefixes_bound():
`
33
33
`g = Graph()
`
34
34
``
35
35
`# prefixes in Graph
`
36
``
`-
assert len(list(g.namespaces())) == len(_NAMESPACE_PREFIXES_CORE)
`
``
36
`+
assert len(list(g.namespaces())) == len(
`
``
37
`+
{**_NAMESPACE_PREFIXES_RDFLIB, **_NAMESPACE_PREFIXES_CORE}
`
``
38
`+
)
`
37
39
`pre = sorted([x[0] for x in list(g.namespaces())])
`
38
``
`-
assert pre == ["owl", "rdf", "rdfs", "xml", "xsd"]
`
``
40
`+
assert pre == [
`
``
41
`+
"brick",
`
``
42
`+
"csvw",
`
``
43
`+
"dc",
`
``
44
`+
"dcam",
`
``
45
`+
"dcat",
`
``
46
`+
"dcmitype",
`
``
47
`+
"dcterms",
`
``
48
`+
"doap",
`
``
49
`+
"foaf",
`
``
50
`+
"geo",
`
``
51
`+
"odrl",
`
``
52
`+
"org",
`
``
53
`+
"owl",
`
``
54
`+
"prof",
`
``
55
`+
"prov",
`
``
56
`+
"qb",
`
``
57
`+
"rdf",
`
``
58
`+
"rdfs",
`
``
59
`+
"schema",
`
``
60
`+
"sh",
`
``
61
`+
"skos",
`
``
62
`+
"sosa",
`
``
63
`+
"ssn",
`
``
64
`+
"time",
`
``
65
`+
"vann",
`
``
66
`+
"void",
`
``
67
`+
"wgs",
`
``
68
`+
"xml",
`
``
69
`+
"xsd",
`
``
70
`+
]
`
39
71
``
40
72
``
41
73
`def test_rdflib_prefixes_bound():
`
`@@ -175,6 +207,40 @@ def test_nman_bind_namespaces(
`
175
207
`@pytest.mark.parametrize(
`
176
208
` ["selector", "expected_bindings"],
`
177
209
` [
`
``
210
`+
(
`
``
211
`+
None,
`
``
212
`+
{
`
``
213
`+
"brick": "https://brickschema.org/schema/Brick#",
`
``
214
`+
"csvw": "http://www.w3.org/ns/csvw#",
`
``
215
`+
"dc": "http://purl.org/dc/elements/1.1/",
`
``
216
`+
"dcat": "http://www.w3.org/ns/dcat#",
`
``
217
`+
"dcmitype": "http://purl.org/dc/dcmitype/",
`
``
218
`+
"dcterms": "http://purl.org/dc/terms/",
`
``
219
`+
"dcam": "http://purl.org/dc/dcam/",
`
``
220
`+
"doap": "http://usefulinc.com/ns/doap#",
`
``
221
`+
"foaf": "http://xmlns.com/foaf/0.1/",
`
``
222
`+
"odrl": "http://www.w3.org/ns/odrl/2/",
`
``
223
`+
"geo": "http://www.opengis.net/ont/geosparql#",
`
``
224
`+
"org": "http://www.w3.org/ns/org#",
`
``
225
`+
"owl": "http://www.w3.org/2002/07/owl#",
`
``
226
`+
"prof": "http://www.w3.org/ns/dx/prof/",
`
``
227
`+
"prov": "http://www.w3.org/ns/prov#",
`
``
228
`+
"qb": "http://purl.org/linked-data/cube#",
`
``
229
`+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
`
``
230
`+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
`
``
231
`+
"schema": "https://schema.org/",
`
``
232
`+
"sh": "http://www.w3.org/ns/shacl#",
`
``
233
`+
"skos": "http://www.w3.org/2004/02/skos/core#",
`
``
234
`+
"sosa": "http://www.w3.org/ns/sosa/",
`
``
235
`+
"ssn": "http://www.w3.org/ns/ssn/",
`
``
236
`+
"time": "http://www.w3.org/2006/time#",
`
``
237
`+
"vann": "http://purl.org/vocab/vann/",
`
``
238
`+
"void": "http://rdfs.org/ns/void#",
`
``
239
`+
"wgs": "https://www.w3.org/2003/01/geo/wgs84_pos#",
`
``
240
`+
"xsd": "http://www.w3.org/2001/XMLSchema#",
`
``
241
`+
"xml": "http://www.w3.org/XML/1998/namespace",
`
``
242
`+
},
`
``
243
`+
),
`
178
244
` (
`
179
245
`"rdflib",
`
180
246
` {
`
`@@ -208,19 +274,39 @@ def test_nman_bind_namespaces(
`
208
274
`"xsd": "http://www.w3.org/2001/XMLSchema#",
`
209
275
`"xml": "http://www.w3.org/XML/1998/namespace",
`
210
276
` },
`
211
``
`-
)
`
``
277
`+
),
`
``
278
`+
(
`
``
279
`+
"core",
`
``
280
`+
{
`
``
281
`+
"owl": "http://www.w3.org/2002/07/owl#",
`
``
282
`+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
`
``
283
`+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
`
``
284
`+
"xsd": "http://www.w3.org/2001/XMLSchema#",
`
``
285
`+
"xml": "http://www.w3.org/XML/1998/namespace",
`
``
286
`+
},
`
``
287
`+
),
`
212
288
` ],
`
213
289
`)
`
214
290
`def test_bound_namespaces_subset(
`
215
``
`-
selector: Any, expected_bindings: Dict[str, str]
`
``
291
`+
selector: Optional[Any], expected_bindings: Dict[str, str]
`
216
292
`) -> None:
`
217
``
`-
graph = Graph(bind_namespaces=selector)
`
``
293
`+
if selector is not None:
`
``
294
`+
graph = Graph(bind_namespaces=selector)
`
``
295
`+
else:
`
``
296
`+
graph = Graph()
`
218
297
`bound_namespaces = dict(
`
219
298
` (key, str(value)) for key, value in graph.namespace_manager.namespaces()
`
220
299
` )
`
221
300
`assert (
`
222
301
`expected_bindings.items() <= bound_namespaces.items()
`
223
302
` ), f"missing items {expected_bindings.items() - bound_namespaces.items()}"
`
``
303
`+
empty_graph = Graph(bind_namespaces="none")
`
``
304
`+
if selector is not None:
`
``
305
`+
nman = NamespaceManager(empty_graph, bind_namespaces=selector)
`
``
306
`+
else:
`
``
307
`+
nman = NamespaceManager(empty_graph)
`
``
308
`+
nman_bound_namespaces = dict((key, str(value)) for key, value in nman.namespaces())
`
``
309
`+
assert bound_namespaces == nman_bound_namespaces
`
224
310
``
225
311
``
226
312
`def test_compute_qname_no_generate() -> None:
`