Skip to content

Commit

Permalink
feat: avoid creation of nested datasets (#796)
Browse files Browse the repository at this point in the history
* feat: avoid creation of nested datasets
  • Loading branch information
m-alisafaee authored Nov 6, 2019
1 parent d54e877 commit 6084c87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions renku/core/management/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def with_dataset(self, name=None, identifier=None):
clean_up_required = False

if dataset is None:
# Avoid nested datasets: name mustn't have '/' in it
if len(Path(name).parts) > 1:
raise errors.ParameterError(
'Dataset name {} is not valid.'.format(name)
)

clean_up_required = True
dataset_ref = None
identifier = str(uuid.uuid4())
Expand Down
8 changes: 8 additions & 0 deletions tests/cli/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ def test_dataset_create_exception_refs(runner, project, client):
assert 'a' in result.output


@pytest.mark.parametrize('name', ['dataset/new', '/dataset', 'dataset/'])
def test_dataset_name_is_valid(client, runner, project, name):
"""Test dataset name has no '/' character to avoid nested datasets."""
result = runner.invoke(cli, ['dataset', 'create', name])
assert 2 == result.exit_code
assert 'is not valid' in result.output


@pytest.mark.parametrize('output_format', DATASETS_FORMATS.keys())
def test_datasets_list_empty(output_format, runner, project):
"""Test listing without datasets."""
Expand Down

0 comments on commit 6084c87

Please sign in to comment.