Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ws condition in create cmd #143

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dem/cli/command/create_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def create_new_dev_env(platform: DevEnvLocalSetup, new_dev_env_descriptor: dict)
return new_dev_env

def create_dev_env(platform: DevEnvLocalSetup, dev_env_name: str) -> DevEnv:
if ' ' in dev_env_name:
stderr.print("The name of the Development Environment cannot contain whitespace characters!")
raise typer.Abort()

dev_env_original = platform.get_dev_env_by_name(dev_env_name)
if dev_env_original is not None:
typer.confirm("The input name is already used by a Development Environment. Overwrite it?",
Expand Down
21 changes: 20 additions & 1 deletion tests/cli/test_create_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,23 @@ def test_execute_failure(mock_DevEnvLocalSetup, mock_create_dev_env, mock_stderr
mock_create_dev_env.assert_called_once_with(mock_dev_env_local_setup, expected_dev_env_name)
mock_dev_env.check_image_availability.assert_called_once_with(mock_dev_env_local_setup.tool_images,
update_tool_images=True)
mock_stderr_print.assert_called_once_with("The installation failed.")
mock_stderr_print.assert_called_once_with("The installation failed.")

@patch("dem.cli.command.create_cmd.stderr.print")
def test_create_dev_env_with_whitespace(mock_stderr_print):
# Test setup
mock_dev_env_local_setup = MagicMock()
mock_dev_env_local_setup.get_dev_env_by_name.return_value = None

mock_tool_images = MagicMock()
mock_dev_env_local_setup.tool_images = mock_tool_images

expected_dev_env_name = "test dev env with space"

# Run unit under test
with pytest.raises(Exception):
create_cmd.create_dev_env(mock_dev_env_local_setup, expected_dev_env_name)

# Check expectations
mock_dev_env_local_setup.get_dev_env_by_name.assert_not_called()
mock_stderr_print.assert_called_once_with("The name of the Development Environment cannot contain whitespace characters!")
Loading