Пример #1
0
    def testWait(self):
        mock_client = mock.MagicMock()

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            magics_impl.grr_request_approval_impl('foo', ['bar'], wait=True)

            mock_client.request_approval_and_wait.assert_called_once_with(
                reason='foo', approvers=['bar'])
            self.assertFalse(mock_client.request_approval.called)
Пример #2
0
def grr_request_approval(line: Text) -> None:
    """Sends approval request to the selected client for the current user.

  Args:
    line: A string representing arguments passed to the magic command.

  Returns:
    Nothing.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    args = grr_request_approval.parser.parse_args(shlex.split(line))
    magics_impl.grr_request_approval_impl(args.reason, args.approvers,
                                          args.wait)
Пример #3
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_request_approval_impl('foo', ['bar'])