Skip to content

Commit

Permalink
fix(cli): fix overwriting dataset tags (#3497)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius authored Jul 7, 2023
1 parent a9994a8 commit 17a49ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions renku/infrastructure/gateway/dataset_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def remove_tag(self, dataset: Dataset, tag: DatasetTag):
for t in tags:
if t.name == tag.name:
tags.remove(t)
project_context.database.remove_from_cache(t)
break

# NOTE: Enable this again once we properly deal with `date_created` on imported Renku datasets
Expand Down
20 changes: 20 additions & 0 deletions tests/cli/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,26 @@ def test_dataset_tag(tmpdir, runner, project, subdirectory):
assert 0 == result.exit_code, format_result_exception(result)


def test_dataset_overwrite_tag(runner, project_with_datasets):
"""Test that dataset tags can be overwritten."""
# tag dataset
result = runner.invoke(cli, ["dataset", "tag", "dataset-1", "1.0"], catch_exceptions=False)
assert 0 == result.exit_code, format_result_exception(result)

# retag
result = runner.invoke(cli, ["dataset", "tag", "dataset-1", "1.0"], catch_exceptions=False)
assert 2 == result.exit_code, format_result_exception(result)
assert "Tag '1.0' already exists" in result.output

# force overwrite
result = runner.invoke(cli, ["dataset", "tag", "--force", "dataset-1", "1.0"], catch_exceptions=False)
assert 0 == result.exit_code, format_result_exception(result)

result = runner.invoke(cli, ["graph", "export", "--format", "json-ld", "--strict"])
assert 0 == result.exit_code, format_result_exception(result)
assert 1 == result.output.count('"@id": "https://localhost/dataset-tags/1.0%40')


@pytest.mark.parametrize("form", ["tabular", "json-ld"])
def test_dataset_ls_tags(tmpdir, runner, project, form):
"""Test listing of dataset tags."""
Expand Down

0 comments on commit 17a49ae

Please sign in to comment.