Skip to content

Commit ce9850f

Browse files
authored
fix(core): fix SHACL shape for MappingParameter and add SHACL checks to more tests (#2811)
1 parent 70682a3 commit ce9850f

11 files changed

+116
-17
lines changed

renku/data/shacl_shape.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,10 +1468,24 @@
14681468
"maxCount": 1
14691469
},
14701470
{
1471-
"path": "schema:mapsTo",
1472-
"sh:class": {
1473-
"@id": "renku:CommandParameterBase"
1474-
}
1471+
"path": "renku:mapsTo",
1472+
"or": [
1473+
{
1474+
"sh:class": {
1475+
"@id": "renku:CommandParameter"
1476+
}
1477+
},
1478+
{
1479+
"sh:class": {
1480+
"@id": "renku:CommandInput"
1481+
}
1482+
},
1483+
{
1484+
"sh:class": {
1485+
"@id": "renku:CommandOutput"
1486+
}
1487+
}
1488+
]
14751489
}
14761490
]
14771491
},

tests/cli/test_datasets.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ def test_multiple_file_to_dataset(tmpdir, runner, project, client, load_dataset_
473473
result = runner.invoke(cli, ["dataset", "add", "dataset"] + paths, catch_exceptions=False)
474474
assert 0 == result.exit_code, format_result_exception(result)
475475

476+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
477+
assert 0 == result.exit_code, format_result_exception(result)
478+
476479

477480
def test_add_with_relative_path(runner, client, directory_tree, subdirectory):
478481
"""Test adding data with relative path."""
@@ -676,8 +679,7 @@ def test_dataset_add_many(tmpdir, runner, project, client):
676679

677680

678681
def test_dataset_file_path_from_subdirectory(runner, client, subdirectory, load_dataset_with_injection):
679-
"""Test adding a file into a dataset and check path independent
680-
of the CWD"""
682+
"""Test adding a file into a dataset and check path independent of the CWD."""
681683
# create a dataset
682684
result = runner.invoke(cli, ["dataset", "create", "dataset"])
683685
assert 0 == result.exit_code, format_result_exception(result)
@@ -992,7 +994,7 @@ def test_dataset_unlink_file_abort_unlinking(tmpdir, runner, project):
992994

993995

994996
def test_dataset_unlink_file(tmpdir, runner, client, subdirectory, load_dataset_with_injection):
995-
"""Test unlinking of file and check removal from dataset"""
997+
"""Test unlinking of file and check removal from dataset."""
996998
# create a dataset
997999
result = runner.invoke(cli, ["dataset", "create", "my-dataset"])
9981000
assert 0 == result.exit_code, format_result_exception(result)
@@ -1039,6 +1041,9 @@ def test_dataset_rm(runner, client, directory_tree, subdirectory, load_dataset_w
10391041
result = runner.invoke(cli, ["doctor"], catch_exceptions=False)
10401042
assert 0 == result.exit_code, format_result_exception(result)
10411043

1044+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
1045+
assert 0 == result.exit_code, format_result_exception(result)
1046+
10421047

10431048
def test_dataset_rm_failure(runner, client):
10441049
"""Test errors in removal of a dataset."""
@@ -1126,6 +1131,9 @@ def test_dataset_edit(runner, client, project, dirty, subdirectory, load_dataset
11261131
assert 1 == len(dataset.annotations)
11271132
assert new_metadata == dataset.annotations[0].body
11281133

1134+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
1135+
assert 0 == result.exit_code, format_result_exception(result)
1136+
11291137

11301138
@pytest.mark.parametrize("dirty", [False, True])
11311139
def test_dataset_edit_no_change(runner, client, project, dirty):
@@ -1171,6 +1179,7 @@ def test_dataset_provider_resolution_dataverse(doi_responses, uri):
11711179

11721180

11731181
def test_dataset_tag(tmpdir, runner, client, subdirectory, get_datasets_provenance_with_injection):
1182+
"""Test that dataset tags can be created."""
11741183
result = runner.invoke(cli, ["dataset", "create", "my-dataset"])
11751184
assert 0 == result.exit_code, format_result_exception(result)
11761185
assert "OK" in result.output
@@ -1200,9 +1209,13 @@ def test_dataset_tag(tmpdir, runner, client, subdirectory, get_datasets_provenan
12001209
all_tags = datasets_provenance.get_all_tags(dataset)
12011210
assert {dataset.id} == {t.dataset_id.value for t in all_tags}
12021211

1212+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
1213+
assert 0 == result.exit_code, format_result_exception(result)
1214+
12031215

12041216
@pytest.mark.parametrize("form", ["tabular", "json-ld"])
12051217
def test_dataset_ls_tags(tmpdir, runner, project, client, form, load_dataset_with_injection):
1218+
"""Test listing of dataset tags."""
12061219
result = runner.invoke(cli, ["dataset", "create", "my-dataset"])
12071220
assert 0 == result.exit_code, format_result_exception(result)
12081221
assert "OK" in result.output
@@ -1238,6 +1251,7 @@ def test_dataset_ls_tags(tmpdir, runner, project, client, form, load_dataset_wit
12381251

12391252

12401253
def test_dataset_rm_tag(tmpdir, runner, client, subdirectory, load_dataset_with_injection):
1254+
"""Test removing of dataset tags."""
12411255
result = runner.invoke(cli, ["dataset", "create", "my-dataset"])
12421256
assert 0 == result.exit_code, format_result_exception(result)
12431257
assert "OK" in result.output
@@ -1273,8 +1287,12 @@ def test_dataset_rm_tag(tmpdir, runner, client, subdirectory, load_dataset_with_
12731287
assert 2 == result.exit_code
12741288
assert "not found" in result.output
12751289

1290+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
1291+
assert 0 == result.exit_code, format_result_exception(result)
1292+
12761293

12771294
def test_dataset_rm_tags_multiple(tmpdir, runner, project, client):
1295+
"""Test removing multiple dataset tags at once."""
12781296
result = runner.invoke(cli, ["dataset", "create", "my-dataset"])
12791297
assert 0 == result.exit_code, format_result_exception(result)
12801298
assert "OK" in result.output
@@ -1300,6 +1318,7 @@ def test_dataset_rm_tags_multiple(tmpdir, runner, project, client):
13001318

13011319

13021320
def test_dataset_rm_tags_failure(tmpdir, runner, project, client):
1321+
"""Test removing non-existent dataset tag."""
13031322
result = runner.invoke(cli, ["dataset", "rm-tags", "my-dataset", "1"], catch_exceptions=False)
13041323

13051324
assert 1 == result.exit_code
@@ -1726,7 +1745,7 @@ def test_external_file_update(runner, client, directory_tree, subdirectory):
17261745
assert current_commit != previous_commit
17271746

17281747

1729-
@pytest.mark.skip("renku update doesn't support new database, reenable once it does")
1748+
@pytest.mark.skip("renku update follows symlinks when calculating hashes and doesn't respect external files")
17301749
@pytest.mark.serial
17311750
def test_workflow_with_external_file(runner, client, directory_tree, run, subdirectory, no_lfs_size_limit):
17321751
"""Check using external files in workflows."""
@@ -2027,6 +2046,9 @@ def test_datasets_provenance_after_update(runner, client, directory_tree, get_da
20272046

20282047
assert current_version.identifier != current_version.initial_identifier
20292048

2049+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
2050+
assert 0 == result.exit_code, format_result_exception(result)
2051+
20302052

20312053
def test_datasets_provenance_after_adding_tag(
20322054
runner, client, get_datasets_provenance_with_injection, load_dataset_with_injection

tests/cli/test_integration_datasets.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def test_dataset_import_real_doi(runner, client, doi, prefix, sleep_after, load_
9797
assert dataset.date_created is None
9898
assert dataset.date_published is not None
9999

100+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
101+
assert 0 == result.exit_code, format_result_exception(result)
102+
100103

101104
@pytest.mark.parametrize(
102105
"doi, input",
@@ -143,6 +146,9 @@ def test_dataset_import_real_param(doi, input, runner, project, sleep_after, cli
143146
result = runner.invoke(cli, ["dataset", "ls"])
144147
assert 0 == result.exit_code, format_result_exception(result) + str(result.stderr_bytes)
145148

149+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
150+
assert 0 == result.exit_code, format_result_exception(result)
151+
146152

147153
@pytest.mark.parametrize(
148154
"doi", [("10.5281/zenodo.3239984", "n"), ("zenodo.org/record/3239986", "n"), ("10.5281/zenodo.3239982", "n")]
@@ -163,7 +169,7 @@ def test_dataset_import_uri_404(doi, runner, project, sleep_after):
163169
@retry_failed
164170
@pytest.mark.vcr
165171
def test_dataset_import_real_doi_warnings(runner, project, sleep_after):
166-
"""Test dataset import for existing DOI and dataset"""
172+
"""Test dataset import for existing DOI and dataset."""
167173
result = runner.invoke(cli, ["dataset", "import", "10.5281/zenodo.1438326"], input="y")
168174
assert 0 == result.exit_code, format_result_exception(result) + str(result.stderr_bytes)
169175
assert "Warning: Newer version found" in result.output
@@ -323,6 +329,9 @@ def test_dataset_import_renku_provider(runner, client, uri, load_dataset_with_in
323329
canonical_uri = "https://dev.renku.ch/datasets/860f6b5b46364c83b6a9b38ef198bcc0"
324330
assert dataset.same_as.url["@id"] == canonical_uri
325331

332+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
333+
assert 0 == result.exit_code, format_result_exception(result)
334+
326335

327336
@pytest.mark.integration
328337
@retry_failed
@@ -482,7 +491,7 @@ def test_dataset_import_renku_provider_errors(runner, project, uri, message):
482491
@pytest.mark.vcr
483492
@pytest.mark.parametrize("url", ["https://dev.renku.ch/datasets/e3e1beba05594fdd8e4682963cec9fe2"])
484493
def test_dataset_reimport_renkulab_dataset(runner, project, url):
485-
"""Test dataset import for existing dataset"""
494+
"""Test dataset import for existing dataset."""
486495
assert 0 == runner.invoke(cli, ["dataset", "import", url], input="y").exit_code
487496

488497
result = runner.invoke(cli, ["dataset", "import", url], input="y")
@@ -558,6 +567,9 @@ def test_dataset_export_upload_file(
558567
assert "Exported to:" in result.output
559568
assert output in result.output
560569

570+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
571+
assert 0 == result.exit_code, format_result_exception(result)
572+
561573

562574
@pytest.mark.integration
563575
@retry_failed

tests/cli/test_move.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def test_move(runner, client):
5151
assert f"{src1} -> {dst1}" in result.output
5252
assert f"{src2} -> {dst2}" in result.output
5353

54+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
55+
assert 0 == result.exit_code, format_result_exception(result)
56+
5457

5558
def test_move_outside_paths(runner, client, directory_tree):
5659
"""Test move from/to outside paths is not possible."""

tests/cli/test_project.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ def test_project_edit(runner, client, subdirectory, client_database_injection_ma
9898
assert "Renku Version:" in result.output
9999
assert "Keywords:" in result.output
100100

101+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
102+
assert 0 == result.exit_code, format_result_exception(result)
103+
101104

102105
def test_project_edit_no_change(runner, client):
103106
"""Check project metadata editing does not commit when there is no change."""

tests/cli/test_rerun.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def rerun():
6666
("𒁃.c", "𒁏.txt"),
6767
],
6868
)
69-
def test_rerun_with_special_paths(project, renku_cli, provider, source, output):
69+
def test_rerun_with_special_paths(project, renku_cli, runner, provider, source, output):
7070
"""Test rerun with unicode/whitespace filenames."""
7171
cwd = Path(project)
7272
source = cwd / source
@@ -88,6 +88,9 @@ def rerun():
8888

8989
assert content != output.read_text().strip(), "The output should have changed."
9090

91+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
92+
assert 0 == result.exit_code, format_result_exception(result)
93+
9194

9295
@pytest.mark.parametrize("provider", available_workflow_providers())
9396
@pytest.mark.parametrize("source, content", [("input1", "input1 new-input2 old"), ("input2", "input1 old-input2 new")])
@@ -295,6 +298,9 @@ def test_rerun_overridden_outputs_partially(project, renku_cli, runner):
295298
assert "r2" in result.output
296299
assert "r3" not in result.output
297300

301+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
302+
assert 0 == result.exit_code, format_result_exception(result)
303+
298304

299305
def test_rerun_multiple_paths_common_output(project, renku_cli, runner):
300306
"""Test when multiple paths generate the same output only the most recent path will be rerun."""

tests/cli/test_rollback.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def test_rollback(client, runner, project):
8383
result = runner.invoke(cli, ["rollback"], input="7\ny")
8484
assert 0 == result.exit_code, format_result_exception(result)
8585

86+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
87+
assert 0 == result.exit_code, format_result_exception(result)
88+
8689
result = runner.invoke(cli, ["workflow", "ls"])
8790
assert 0 == result.exit_code, format_result_exception(result)
8891
assert 2 == len(result.output.splitlines())

tests/cli/test_run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_run_external_command_file(runner, client, project, run_shell, client_da
9595
assert plan.command.endswith("/echo")
9696

9797

98-
def test_run_metadata(renku_cli, client, client_database_injection_manager):
98+
def test_run_metadata(renku_cli, runner, client, client_database_injection_manager):
9999
"""Test run with workflow metadata."""
100100
exit_code, activity = renku_cli(
101101
"run", "--name", "run-1", "--description", "first run", "--keyword", "key1", "--keyword", "key2", "touch", "foo"
@@ -114,6 +114,9 @@ def test_run_metadata(renku_cli, client, client_database_injection_manager):
114114
assert "first run" == plan.description
115115
assert {"key1", "key2"} == set(plan.keywords)
116116

117+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
118+
assert 0 == result.exit_code, format_result_exception(result)
119+
117120

118121
@pytest.mark.parametrize(
119122
"command, name",

tests/cli/test_template.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def test_template_set(runner, client, client_database_injection_manager):
146146
assert __template_version__ == client.project.template_version
147147
assert __template_version__ == client.project.template_ref
148148

149+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
150+
assert 0 == result.exit_code, format_result_exception(result)
151+
149152

150153
def test_template_set_overwrites_modified(runner, client, client_database_injection_manager):
151154
"""Test setting a new template in a project overwrite modified files."""
@@ -230,6 +233,9 @@ def test_template_update(runner, client, client_database_injection_manager):
230233
assert 0 == result.exit_code, format_result_exception(result)
231234
assert "Template is up-to-date" in result.output
232235

236+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
237+
assert 0 == result.exit_code, format_result_exception(result)
238+
233239

234240
def test_template_update_latest_version(runner, client):
235241
"""Test updating template that is the latest version."""

tests/cli/test_update.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def test_update(runner, client, renku_cli, client_database_injection_manager, pr
6464
# NOTE: No ActivityCollection is created if update include only one activity
6565
assert [] == activity_collections
6666

67+
result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
68+
assert 0 == result.exit_code, format_result_exception(result)
69+
6770

6871
@pytest.mark.parametrize("provider", available_workflow_providers())
6972
def test_update_multiple_steps(runner, client, renku_cli, client_database_injection_manager, provider):

0 commit comments

Comments
 (0)