|
12 | 12 | from schema_salad.sourceline import cmap
|
13 | 13 |
|
14 | 14 | from .util import get_data
|
| 15 | +from .test_cli_args import captured_output |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def test_errors() -> None:
|
@@ -77,8 +78,7 @@ def test_error_message2() -> None:
|
77 | 78 |
|
78 | 79 | t = "test_schema/test2.cwl"
|
79 | 80 | match = r"""
|
80 |
| -^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference\s+to |
81 |
| -\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[ |
| 81 | +^.+test2\.cwl:2:1: Field `class`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/schema_salad/tests/test_schema/xWorkflow`$"""[ |
82 | 82 | 1:
|
83 | 83 | ]
|
84 | 84 | path2 = get_data("tests/" + t)
|
@@ -182,8 +182,7 @@ def test_error_message8() -> None:
|
182 | 182 | match = r"""
|
183 | 183 | ^.+test8\.cwl:7:1: checking field\s+`steps`
|
184 | 184 | .+test8\.cwl:8:3: checking object\s+`.+test8\.cwl#step1`
|
185 |
| -.+test8\.cwl:9:5: Field\s+`scatterMethod`\s+contains\s+undefined\s+reference\s+to |
186 |
| -\s+`file:///.+/tests/test_schema/abc`$"""[ |
| 185 | +.+test8\.cwl:9:5: Field\s+`scatterMethod`\s+contains\s+undefined\s+reference\s+to\s+`file:///.+/tests/test_schema/abc`$"""[ |
187 | 186 | 1:
|
188 | 187 | ]
|
189 | 188 | with pytest.raises(ValidationException, match=match):
|
@@ -245,8 +244,7 @@ def test_error_message11() -> None:
|
245 | 244 | match = r"""
|
246 | 245 | ^.+test11\.cwl:7:1: checking field\s+`steps`
|
247 | 246 | .+test11\.cwl:8:3: checking object\s+`.+test11\.cwl#step1`
|
248 |
| -.+test11\.cwl:9:5: Field `run`\s+contains\s+undefined\s+reference\s+to |
249 |
| -\s+`file://.+/tests/test_schema/blub\.cwl`$"""[ |
| 247 | +.+test11\.cwl:9:5: Field `run`\s+contains\s+undefined\s+reference\s+to\s+`file://.+/tests/test_schema/blub\.cwl`$"""[ |
250 | 248 | 1:
|
251 | 249 | ]
|
252 | 250 | with pytest.raises(ValidationException, match=match):
|
@@ -348,6 +346,74 @@ def test_namespaces_type() -> None:
|
348 | 346 | )
|
349 | 347 |
|
350 | 348 |
|
| 349 | +def test_namespaces_undeclared(caplog: pytest.LogCaptureFixture) -> None: |
| 350 | + """Confirm warning message a namespace is used but not declared.""" |
| 351 | + |
| 352 | + ldr, _, _, _ = schema_salad.schema.load_schema( |
| 353 | + cmap( |
| 354 | + { |
| 355 | + "$base": "Y", |
| 356 | + "name": "X", |
| 357 | + "$graph": [ |
| 358 | + { |
| 359 | + "name": "namesp:ExampleType", |
| 360 | + "type": "enum", |
| 361 | + "symbols": ["asym", "bsym"], |
| 362 | + } |
| 363 | + ], |
| 364 | + } |
| 365 | + ) |
| 366 | + ) |
| 367 | + |
| 368 | + match = r""".*URI prefix 'namesp' of 'namesp:ExampleType' not recognized, are you missing a \$namespaces section?.*""" |
| 369 | + |
| 370 | + assert re.match(match, caplog.text) |
| 371 | + |
| 372 | + |
| 373 | +def test_not_a_namespace1(caplog: pytest.LogCaptureFixture) -> None: |
| 374 | + """Confirm warning message a namespace is used but not declared.""" |
| 375 | + |
| 376 | + ldr, _, _, _ = schema_salad.schema.load_schema( |
| 377 | + cmap( |
| 378 | + { |
| 379 | + "$base": "Y", |
| 380 | + "name": "X", |
| 381 | + "$graph": [ |
| 382 | + { |
| 383 | + "name": "foo/colon:ExampleType", |
| 384 | + "type": "enum", |
| 385 | + "symbols": ["asym", "bsym"], |
| 386 | + } |
| 387 | + ], |
| 388 | + } |
| 389 | + ) |
| 390 | + ) |
| 391 | + |
| 392 | + assert caplog.text == "" |
| 393 | + |
| 394 | + |
| 395 | +def test_not_a_namespace2(caplog: pytest.LogCaptureFixture) -> None: |
| 396 | + """Confirm warning message a namespace is used but not declared.""" |
| 397 | + |
| 398 | + ldr, _, _, _ = schema_salad.schema.load_schema( |
| 399 | + cmap( |
| 400 | + { |
| 401 | + "$base": "Y", |
| 402 | + "name": "X", |
| 403 | + "$graph": [ |
| 404 | + { |
| 405 | + "name": "foo#colon:ExampleType", |
| 406 | + "type": "enum", |
| 407 | + "symbols": ["asym", "bsym"], |
| 408 | + } |
| 409 | + ], |
| 410 | + } |
| 411 | + ) |
| 412 | + ) |
| 413 | + |
| 414 | + assert caplog.text == "" |
| 415 | + |
| 416 | + |
351 | 417 | def test_schemas_type() -> None:
|
352 | 418 | """Confirm helpful error message when $schemas is the wrong type."""
|
353 | 419 | path = get_data("tests/EDAM.owl")
|
|
0 commit comments