Example #1
0
    def testWarnAboutDestructiveActionRejected(self, promptWithTimeoutMock,
                                               _modelCheckpointMgrModuleMock,
                                               _messageBusConnectorClassMock,
                                               _amqpModuleMock,
                                               _repositoryMock):
        # NOTE: rejection can be anything other than the expected input of
        # "Yes-<randint>"
        promptWithTimeoutMock.return_value = "No"

        with self.assertRaises(
                reset_all_taurus_engine_data.UserAbortedOperation):
            reset_all_taurus_engine_data._warnAboutDestructiveAction()
  def testWarnAboutDestructiveActionRejected(self,
                                             promptWithTimeoutMock,
                                             _modelCheckpointMgrModuleMock,
                                             _messageBusConnectorClassMock,
                                             _amqpModuleMock,
                                             _repositoryMock):
    # NOTE: rejection can be anything other than the expected input of
    # "Yes-<randint>"
    promptWithTimeoutMock.return_value = "No"

    with self.assertRaises(reset_all_taurus_engine_data.UserAbortedOperation):
      reset_all_taurus_engine_data._warnAboutDestructiveAction()
Example #3
0
    def testWarnAboutDestructiveActionTimedOut(self, promptWithTimeoutMock,
                                               _modelCheckpointMgrModuleMock,
                                               _messageBusConnectorClassMock,
                                               _amqpModuleMock,
                                               _repositoryMock):

        # NOTE: py.test by default captures console output and patches console input
        # such that raw_input fails. Although not ideal, we have to patch
        # raw_input with something else that blocks and will be interrupted by
        # SIGINT.
        promptWithTimeoutMock.side_effect = nta.utils.prompt_utils.PromptTimeout

        with self.assertRaises(nta.utils.prompt_utils.PromptTimeout):
            reset_all_taurus_engine_data._warnAboutDestructiveAction()
  def testWarnAboutDestructiveActionTimedOut(self,
                                             promptWithTimeoutMock,
                                             _modelCheckpointMgrModuleMock,
                                             _messageBusConnectorClassMock,
                                             _amqpModuleMock,
                                             _repositoryMock):

    # NOTE: py.test by default captures console output and patches console input
    # such that raw_input fails. Although not ideal, we have to patch
    # raw_input with something else that blocks and will be interrupted by
    # SIGINT.
    promptWithTimeoutMock.side_effect = nta.utils.prompt_utils.PromptTimeout

    with self.assertRaises(nta.utils.prompt_utils.PromptTimeout):
      reset_all_taurus_engine_data._warnAboutDestructiveAction()
  def testWarnAboutDestructiveActionConfirmed(self,  # pylint: disable=R0201
                                              randintMock,
                                              promptWithTimeoutMock,
                                              _modelCheckpointMgrModuleMock,
                                              _messageBusConnectorClassMock,
                                              _amqpModuleMock,
                                              _repositoryMock):
    randintMock.return_value = 1
    promptWithTimeoutMock.return_value = "Yes-1"

    reset_all_taurus_engine_data._warnAboutDestructiveAction()

    promptWithTimeoutMock.assert_called_once_with(
      promptText=ANY,
      timeout=reset_all_taurus_engine_data._WARNING_PROMPT_TIMEOUT_SEC)
Example #6
0
    def testWarnAboutDestructiveActionConfirmed(
            self,  # pylint: disable=R0201
            randintMock,
            promptWithTimeoutMock,
            _modelCheckpointMgrModuleMock,
            _messageBusConnectorClassMock,
            _amqpModuleMock,
            _repositoryMock):
        randintMock.return_value = 1
        promptWithTimeoutMock.return_value = "Yes-1"

        reset_all_taurus_engine_data._warnAboutDestructiveAction()

        promptWithTimeoutMock.assert_called_once_with(
            promptText=ANY,
            timeout=reset_all_taurus_engine_data._WARNING_PROMPT_TIMEOUT_SEC)