diff --git a/dem/cli/command/create_cmd.py b/dem/cli/command/create_cmd.py index a079ad1..cf10ba9 100644 --- a/dem/cli/command/create_cmd.py +++ b/dem/cli/command/create_cmd.py @@ -146,8 +146,6 @@ def create_new_dev_env(platform: Platform, new_dev_env_descriptor: dict) -> DevE new_dev_env = DevEnv(new_dev_env_descriptor) platform.local_dev_envs.append(new_dev_env) - return new_dev_env - def create_dev_env(platform: Platform, dev_env_name: str) -> DevEnv: if ' ' in dev_env_name: stderr.print("The name of the Development Environment cannot contain whitespace characters!") @@ -163,22 +161,11 @@ def create_dev_env(platform: Platform, dev_env_name: str) -> DevEnv: if dev_env_original is not None: overwrite_existing_dev_env(dev_env_original, new_dev_env_descriptor) - new_dev_env = dev_env_original else: - new_dev_env = create_new_dev_env(platform, new_dev_env_descriptor) - - return new_dev_env + create_new_dev_env(platform, new_dev_env_descriptor) def execute(platform: Platform, dev_env_name: str) -> None: - dev_env = create_dev_env(platform, dev_env_name) - - # Validate the Dev Env creation - image_statuses = dev_env.check_image_availability(platform.tool_images, - update_tool_image_store=True) - - if (ToolImages.NOT_AVAILABLE in image_statuses) or (ToolImages.REGISTRY_ONLY in image_statuses): - stderr.print("The installation failed.") - else: - platform.flush_descriptors() - stdout.print(f"The [green]{dev_env_name}[/] Development Environment has been created!") - stdout.print("Run [italic]dem install[/] to install it.") \ No newline at end of file + create_dev_env(platform, dev_env_name) + platform.flush_descriptors() + stdout.print(f"The [green]{dev_env_name}[/] Development Environment has been created!") + stdout.print("Run [italic]dem install[/] to install it.") \ No newline at end of file diff --git a/dem/cli/command/uninstall_cmd.py b/dem/cli/command/uninstall_cmd.py index e4199ad..b7b2339 100644 --- a/dem/cli/command/uninstall_cmd.py +++ b/dem/cli/command/uninstall_cmd.py @@ -25,4 +25,4 @@ def execute(platform: Platform, dev_env_name: str) -> None: except PlatformError as e: stderr.print(f"[red]Error: {str(e)}[/]") else: - stdout.print(f"[green]Successfully deleted the {dev_env_name}![/]") \ No newline at end of file + stdout.print(f"[green]Successfully uninstalled the {dev_env_name}![/]") \ No newline at end of file diff --git a/dem/cli/main.py b/dem/cli/main.py index a831333..221d5f8 100644 --- a/dem/cli/main.py +++ b/dem/cli/main.py @@ -404,10 +404,5 @@ def main( Development Environment Manager (dem) Manage your containerized Development Environments with ease. - - - - ❗ Always put the input text into double quotation marks (""), if it contains whitespaces. - """ return diff --git a/docs/commands.md b/docs/commands.md index f3add48..47b601c 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1,7 +1,3 @@ -!!! warning - - Always put the input text into double quotation marks ("") if it contains whitespaces. - ## **`dem list [OPTIONS]`** List the Development Environments installed locally or available in the catalog. diff --git a/tests/cli/test_create_cmd.py b/tests/cli/test_create_cmd.py index 8366139..947402d 100644 --- a/tests/cli/test_create_cmd.py +++ b/tests/cli/test_create_cmd.py @@ -66,11 +66,9 @@ def test_create_new_dev_env(mock_DevEnvLocal): mock_new_dev_env_descriptor = MagicMock() # Run unit under test - actual_new_dev_env = create_cmd.create_new_dev_env(mock_platform, - mock_new_dev_env_descriptor) + create_cmd.create_new_dev_env(mock_platform, mock_new_dev_env_descriptor) # Check expectations - assert actual_new_dev_env == mock_new_dev_env mock_DevEnvLocal.assert_called_once_with(mock_new_dev_env_descriptor) mock_platform.local_dev_envs.append.assert_called_once_with(mock_new_dev_env) @@ -95,11 +93,9 @@ def test_create_dev_env_new(mock_get_tool_image_list, mock_get_dev_env_descripto expected_dev_env_name = "test_dev_env" # Run unit under test - actual_dev_env = create_cmd.create_dev_env(mock_dev_env_local_setup, expected_dev_env_name) + create_cmd.create_dev_env(mock_dev_env_local_setup, expected_dev_env_name) # Check expectations - assert actual_dev_env == mock_new_dev_env - mock_dev_env_local_setup.get_dev_env_by_name.assert_called_once_with(expected_dev_env_name) mock_get_tool_image_list.assert_called_once_with(mock_dev_env_local_setup.tool_images) mock_get_dev_env_descriptor_from_user.assert_called_once_with(expected_dev_env_name, mock_tool_images) @@ -130,11 +126,9 @@ def test_create_dev_env_overwrite(mock_confirm, mock_get_tool_image_list, expected_dev_env_name = "test_dev_env" # Run unit under test - actual_dev_env = create_cmd.create_dev_env(mock_dev_env_local_setup, expected_dev_env_name) + create_cmd.create_dev_env(mock_dev_env_local_setup, expected_dev_env_name) # Check expectations - assert actual_dev_env == mock_dev_env_original - mock_dev_env_local_setup.get_dev_env_by_name.assert_called_once_with(expected_dev_env_name) mock_confirm.assert_called_once_with("The input name is already used by a Development Environment. Overwrite it?", abort=True) @@ -173,11 +167,6 @@ def test_execute(mock_create_dev_env, mock_stdout_print): mock_dev_env = MagicMock() expected_dev_env_name = "test_dev_env" - mock_dev_env.name = expected_dev_env_name - mock_create_dev_env.return_value = mock_dev_env - - image_statuses = [ToolImages.LOCAL_AND_REGISTRY, ToolImages.LOCAL_ONLY] * 2 - mock_dev_env.check_image_availability.return_value = image_statuses # Run unit under test runner_result = runner.invoke(main.typer_cli, ["create", expected_dev_env_name], color=True) @@ -186,8 +175,6 @@ def test_execute(mock_create_dev_env, mock_stdout_print): assert 0 == runner_result.exit_code mock_create_dev_env.assert_called_once_with(mock_platform, expected_dev_env_name) - mock_dev_env.check_image_availability.assert_called_once_with(mock_platform.tool_images, - update_tool_image_store=True) mock_platform.flush_descriptors.assert_called_once() mock_stdout_print.assert_has_calls([ call(f"The [green]{expected_dev_env_name}[/] Development Environment has been created!"), @@ -201,12 +188,6 @@ def test_execute_failure(mock_create_dev_env, mock_stderr_print): mock_platform = MagicMock() main.platform = mock_platform - mock_dev_env = MagicMock() - mock_create_dev_env.return_value = mock_dev_env - - image_statuses = [ToolImages.NOT_AVAILABLE] * 5 - mock_dev_env.check_image_availability.return_value = image_statuses - expected_dev_env_name = "test_dev_env" # Run unit under test @@ -216,9 +197,6 @@ def test_execute_failure(mock_create_dev_env, mock_stderr_print): assert 0 == runner_result.exit_code mock_create_dev_env.assert_called_once_with(mock_platform, expected_dev_env_name) - mock_dev_env.check_image_availability.assert_called_once_with(mock_platform.tool_images, - update_tool_image_store=True) - 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): diff --git a/tests/cli/test_uninstall_cmd.py b/tests/cli/test_uninstall_cmd.py index dfc5c9b..ff2159a 100644 --- a/tests/cli/test_uninstall_cmd.py +++ b/tests/cli/test_uninstall_cmd.py @@ -47,7 +47,7 @@ def test_uninstall_dev_env_valid_name(mock_stdout_print): mock_platform.get_dev_env_by_name.assert_called_once_with(fake_dev_env_to_uninstall.name ) mock_platform.uninstall_dev_env.assert_called_once_with(fake_dev_env_to_uninstall) - mock_stdout_print.assert_called_once_with(f"[green]Successfully deleted the {fake_dev_env_to_uninstall.name}![/]") + mock_stdout_print.assert_called_once_with(f"[green]Successfully uninstalled the {fake_dev_env_to_uninstall.name}![/]") @patch("dem.cli.command.uninstall_cmd.stderr.print") def test_uninstall_dev_env_valid_name_not_installed(mock_stderr_print):