Skip to content

Commit

Permalink
Added test in test_create_cmd to ensure create_cmd works as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscarnold committed Oct 29, 2023
1 parent 831899d commit 345c102
Showing 1 changed file with 20 additions and 1 deletion.
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!")

0 comments on commit 345c102

Please sign in to comment.