Beispiel #1
0
    def testWithClientSet(self):
        mock_client = _MockClient()
        mock_client.set_hostname('foobar')

        with mock.patch.object(magics_impl._state, 'client', mock_client):
            hostname = magics_impl.grr_hostname_impl()

        self.assertEqual(hostname, 'foobar')
Beispiel #2
0
def grr_hostname(line: Text) -> Text:
    """Returns hostname of the selected client.

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

  Returns:
    String representing hostname of a client.

  Raises:
    NoClientSelectedError: Client is not selected to perform this operation.
  """
    del line  # Unused.
    return magics_impl.grr_hostname_impl()
Beispiel #3
0
 def testNoClientSelected(self):
     with self.assertRaises(magics_impl.NoClientSelectedError):
         magics_impl.grr_hostname_impl()