def test_invoke_exception(self) -> None:
   self.side_effect = exceptions.DevContainerException("message", exit_code=1)
   m_click, m_container, m_sys = self.invoke_command()
   m_container.assert_called_once_with()
   m_container.return_value.get_container_version.assert_called_once()
   m_click.echo.assert_called_once_with('No PIB container found.')
   m_sys.exit.assert_called_once_with(
       m_container.return_value.incompatible_container_exit_code
   )
  def test_invoke_container_only_cannot_execute(self) -> None:
    error_message = "test_message"
    exit_code = 1
    self.test_exception = exceptions.DevContainerException(
        error_message, exit_code=exit_code
    )

    m_click, m_exit, _ = self.invoke_command()
    m_click.echo.assert_called_once_with(f"ERROR: {error_message}")
    m_exit.assert_called_once_with()
示例#3
0
    def test_invoke_container_only_cannot_execute(self) -> None:
        error_message = "test_message"

        with patch.object(self.instance.command_configuration,
                          "is_executable_exception") as m_executable:
            exit_code = 1
            mock_exception = exceptions.DevContainerException(
                error_message, exit_code=exit_code)
            m_executable.side_effect = mock_exception
            _, m_exit, m_click = self.invoke_command()

        m_click.echo.assert_called_once_with(f"ERROR: {error_message}")
        m_exit.assert_called_once_with(exit_code)
示例#4
0
 def create_patched_instance(
     self,
     selected_configuration: TypeYamlConfig,
     valid_container: bool,
 ) -> command_selector_base.CommandSelectorBase:
   with patch(
       command_selector_base.__name__ + ".container.DevContainer"
   ) as m_container:
     if not valid_container:
       valid = m_container.return_value.container_valid_exception
       valid.side_effect = exceptions.DevContainerException(
           "message", exit_code=1
       )
     return self.test_class(selected_configuration)
示例#5
0
 def setUp(self) -> None:
   self.message = "Test Exception"
   self.exit_code = 0
   self.instance = exceptions.DevContainerException(
       self.message, exit_code=self.exit_code
   )